admin管理员组文章数量:1391990
I'm setting up work with my django app, but I ran into a problem when checking for any file in S3 storage.
I can't figure out why I can't use the exists() method in my code. I searched for an error for a long time, but it turned out that the exists() method always returns False to me.
Here is an example:
>>> from django.core.files.storage import default_storage
>>> print(default_storage.listdir(""))
(['media', 'preview'], ['address_preview_1.png','address_preview_35.jpg'])
>>>
>>> print(default_storage.listdir("media"))
([], ['address_preview_35.jpg'])
>>> print(default_storage.exists('address_preview_35.jpg'))
False
>>> print(default_storage.exists('/media/address_preview_35.jpg'))
False
>>> print(default_storage.exists('media/address_preview_35.jpg'))
False
>>> print(default_storage.location)
media
We see that the file "address_preview_35.jpg " there is both in the root of the repository and in the "media" folder.
All arguments in settings.py are configured as described in the documentation. The image files are definitely on the server. We can open it. We can get the image from the full link. We can upload new files to the server and we can delete old ones. We can do everything EXCEPT check whether there is a file on the server or not. What am I doing wrong!?
I tried accessing the server directly and via s3cmd. I tried accessing the repository in the module via
from storages.backends.s3boto3 import S3Boto3Storage
s3_storage = S3Boto3Storage()
print(s3_storage.exists("media/address_preview_35.jpg"))
the result is the same - I see the file in the list, but when checking exists(), I get False.
本文标签: amazon web servicesDjango defaultstorage cant find an existing fileStack Overflow
版权声明:本文标题:amazon web services - Django default_storage can`t find an existing file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744743598a2622756.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论