@@ -278,48 +278,7 @@ func (d *S3) Get(ctx context.Context, path string) (model.Obj, error) {
278278 return nil , errors .WithMessage (err , "failed to head object" )
279279 }
280280
281- // If HeadObject fails with 404, check if it's a directory
282- prefix := getKey (path , true )
283- var contents []* s3.Object
284- var commonPrefixes []* s3.CommonPrefix
285- switch d .ListObjectVersion {
286- case "v1" :
287- listInput := & s3.ListObjectsInput {
288- Bucket : & d .Bucket ,
289- Prefix : & prefix ,
290- MaxKeys : aws .Int64 (1 ), // Only need to check if at least one object exists
291- }
292- listResult , err := d .client .ListObjectsWithContext (ctx , listInput )
293- if err != nil {
294- return nil , errors .WithMessage (err , "failed to list objects with prefix" )
295- }
296- contents = listResult .Contents
297- commonPrefixes = listResult .CommonPrefixes
298- case "v2" :
299- listInput := & s3.ListObjectsV2Input {
300- Bucket : & d .Bucket ,
301- Prefix : & prefix ,
302- MaxKeys : aws .Int64 (1 ),
303- }
304- listResult , err := d .client .ListObjectsV2WithContext (ctx , listInput )
305- if err != nil {
306- return nil , errors .WithMessage (err , "failed to list objects v2 with prefix" )
307- }
308- contents = listResult .Contents
309- commonPrefixes = listResult .CommonPrefixes
310- default :
311- return nil , fmt .Errorf ("unsupported ListObjectVersion: %s" , d .ListObjectVersion )
312- }
313- if len (contents ) > 0 || len (commonPrefixes ) > 0 {
314- dirName := stdpath .Base (path + "/" )
315- return & model.Object {
316- Name : dirName ,
317- Modified : d .Modified ,
318- IsFolder : true ,
319- Path : path ,
320- }, nil
321- }
322- return nil , errs .ObjectNotFound
281+ return nil , errs .NotSupport
323282}
324283
325284var _ driver.Driver = (* S3 )(nil )
0 commit comments