How can you tell if an object is a folder on AWS S3

后端 未结 4 1799
孤城傲影
孤城傲影 2021-02-18 22:17

I doesn\'t appear in the meta data--whether an object is a folder or not. Is there a specific method you guys on SO know of? I can\'t find anything of worth in Google search.<

4条回答
  •  感动是毒
    2021-02-18 22:30

    3 years into the future of the OP, I am providing my answer since this appeared in a recent Google Search.

    The concept of "directories" is a little more refined in S3 these days, with these objects receiving a content-type of "application/x-directory".

    As such, if you're using the AWS Ruby SDK (version 1), you can simply use:

    s3_client.buckets['some_bucket'].objects['some_directory_object'].content_type
    

提交回复
热议问题