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

后端 未结 4 1800
孤城傲影
孤城傲影 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:31

    There is no folder concept on S3. All objects have a key (like name) and keys can contain special characters like / (slash). This gives us a feel of folders.

    When you list the bucket contents it returns the list of all the objects (and the keys). Then you can see if the key string contains slash (/). If it contains, then understand the object is in a "folder like" structure. That way you get the full details.

    "A response can contain CommonPrefixes only if you specify a delimiter. When you do, CommonPrefixes contains all (if there are any) keys between Prefix and the next occurrence of the string specified by delimiter. In effect, CommonPrefixes lists keys that act like subdirectories in the directory specified by Prefix. For example, if prefix is notes/ and delimiter is a slash (/), in notes/summer/july, the common prefix is notes/summer/. All of the keys rolled up in a common prefix count as a single return when calculating the number of returns. See MaxKeys." http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGET.html

提交回复
热议问题