简体   繁体   English

s3boto的异常行为

[英]Unexpected behavior for s3boto

I'm working with amazon S3 storage and have unexpected behavior: storage.exists() returns False for directories. 我正在使用Amazon S3存储,并且有意外的行为:storage.exists()对于目录返回False。 Am I doing everything right? 我做对了吗? As I understand django documentation, it should return True https://docs.djangoproject.com/en/dev/ref/files/storage/ 据我了解django文档,它应该返回True https://docs.djangoproject.com/en/dev/ref/files/storage/

from storages.backends.s3boto import S3BotoStorage

s = S3BotoStorage(bucket='bucketname')
s.listdir('.')
    ([u'test_elf'], [u'327.jpg',u'avatar2.jpg'])
s.exists(u'avatar2.jpg')
    True
s.exists(u'test_elf')
    False  <-- ??

s3 only emulates folders. s3仅模拟文件夹。 If you have such structure of files on s3 如果您在s3上具有这种文件结构

avatar1.jpg
avatar2.jpg
folder --
          avatar3.jpg
          avatar4.jpg
one_more.png
last_image.jpg

than you have 6 logical instances on your bucket: 您的存储桶中有6个逻辑实例:

avatar1.jpg
avatar2.jpg
folder/avatar3.jpg
folder/avatar4.jpg
one_more.png
last_image.jpg

I think you are free to create a file "folder" in the root wich will be incompartable with a usual filesystem structure but possible on s3. 我认为您可以自由地在根目录中创建文件“文件夹”,这与通常的文件系统结构无与伦比,但在s3上是可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM