stephenmcd / filebrowser-safe

File manager for Mezzanine
Other
41 stars 104 forks source link

Fixed issue with s3.Bucket object does not support method 'list' any longer #111

Closed ykoasanto closed 6 years ago

ykoasanto commented 6 years ago

This should fix the issue described in https://github.com/stephenmcd/filebrowser-safe/issues/104 This is caused by mismatch of boto version. Django-storages has been updated to use boto3, while filebrowser-safe assumes that the self.bucket was created using boto2. The method s3.bucket.list exists only in boto2.

The fix is to use listdir in S3Boto3Storage, which in turn is using self.bucket.objects.filter(Prefix=self._encode_name(name)) to list the content of the bucket

Reference for methods supported in boto3 http://boto3.readthedocs.io/en/latest/reference/services/s3.html?highlight=s3#bucket

Reference for methods supported in boto2 http://boto.cloudhackers.com/en/latest/ref/s3.html#module-boto.s3.bucket

stephenmcd commented 6 years ago

It's intended to fix use of s3 but you've only modified code in the GoogleStorageMixin class.

Is that right?

ykoasanto commented 6 years ago

@stephenmcd: I modified two lines: 85 and 115 both is in S3BotoStorageMixin. I am just not familiar with the integration test to be able move forward, but I've been using this code in my fork and it's working fine so far.

stephenmcd commented 6 years ago

Sorry I was looking at the wrong version of the file.

stephenmcd commented 6 years ago

Also the tests are unrelated to your changes.

Thanks for the fix.