Django Filebrowser与storage services效果不佳。
在Django Filer上发现的Django Packages似乎是一个不错的选择,但它对存储后端的支持似乎不完整。
我想知道Django的文件浏览器的其他替代方案是什么,可以很好地与S3集成。
我在我的项目中使用过https://github.com/bradleyg/django-s3direct。它工作得很好。它也列在你提到的Django Packages网站上。
当您包含S3BotoStorageMixin
时,此程序包应该能够在S3上运行。
from filebrowser.storage import S3BotoStorageMixin
from storages.backends.s3boto import S3BotoStorage
class CustomS3BotoStorage(S3BotoStorageMixin, S3BotoStorage):
def path(self, name):
# Workaround for django-filebrowser, which requests full_path on uploaded files.
# The operation is not needed at all, since no chmod happens afterwards.
return self.url(name)
def isfile(self, name):
# Hacky performance optimization for filebrowser.
# The original isdir() method is really inefficient.
if '.' in name:
return True
return super().isfile(name)
在settings.py
:
DEFAULT_FILE_STORAGE = 'myproject.lib.storages.CustomS3BotoStorage'