Open ny2292000 opened 6 years ago
As far as I can tell this issue is actually less to do with filebrowser-safe and more to do with the django-storages app as the s3boto3 backend does not include the listdir method that filebrowser-safe is looking for.
I have created a basic fork of django-storages which should rectify this at https://github.com/petedermott/django-storages Be aware that for speed purposes I use a very basic check to check if files are directories that makes use of the FILEBROWSER_EXTENSION setting
Try using class MediaStorage(S3BotoStorage, S3BotoStorageMixin). It should work.
@ny2292000: please see my pull request above. That's fixed the issue for me.
When I try to read the Media Library while connected to my S3 Static repository, I get this error. It seems that boto3 doesn't have a list method.
Everything works fine when I use a local Static folder.
ERRROR MESSAGE:
http://127.0.0.1:8080/energy/admin/media-library/browse/ 1.10.8 AttributeError 's3.Bucket' object has no attribute 'list' /Users/user1/anaconda/envs/QS36/lib/python3.6/site-packages/filebrowser_safe/storage.py in isdir, line 85 /Users/user1/anaconda/envs/QS36/bin/python 3.6.2 ['/Users/user1/GitHub/WebPresence/qsunifybanner', '/Users/user1/anaconda/envs/QS36/lib/python36.zip', '/Users/user1/anaconda/envs/QS36/lib/python3.6', '/Users/user1/anaconda/envs/QS36/lib/python3.6/lib-dynload', '/Users/user1/.local/lib/python3.6/site-packages', '/Users/user1/anaconda/envs/QS36/lib/python3.6/site-packages']
SETTINGS: f = os.path.join(PROJECT_APP_PATH, "local_settings.py") if os.path.exists(f): import sys import imp module_name = "%s.local_settings" % PROJECT_APP module = imp.new_module(module_name) module.file = f sys.modules[module_name] = module exec(open(f, "rb").read())
else: ########### Bucket and creds AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME') AWS_PRELOAD_METADATA = True # helps collectstatic do updates ########## Optional settings STATIC_ROOT = os.path.join(PROJECT_ROOT, "static")
Static storage
#############################################
If using django-compressor it needs to temp cache files somewhere
CUSTOM STORAGE: class CachedS3BotoStorage(S3Boto3Storage): """ S3 storage backend that saves the files locally, too. """ def init(self, *args, *kwargs): super(CachedS3BotoStorage, self).init(args, **kwargs) self.local_storage = get_storage_class( "compressor.storage.CompressorFileStorage")()
class MediaStorage(S3Boto3Storage, S3BotoStorageMixin): location = settings.MEDIAFILES_LOCATION
StaticStorage = lambda: CachedS3BotoStorage(location=settings.STATICFILES_LOCATION)