-
-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-seekable streams can not be uploaded to S3 #860
Comments
Same issue here unfortunately 🙀 |
Hi, the |
Compression would still work, because it does a django-storages/storages/backends/s3boto3.py Line 138 in d827841
This particular section of the code (writing to a file) does not make sense if the file is not seekable though, so it's reasonable to blow up in such circumstances. |
+1 for fixing this problem. I don't understand the code 100% but maybe adding an
In file |
BTW, default django file storage does allow saving non-seekable streams (e. g. like |
@belkka Although a useful workaround, that requires using a different interface and worth noting that it is unfortunately harmful if considered a final suggestion in terms of interoperability with 3rd party applications - which is the case that I had run into |
@monokrome Did you reply to @ramast? I have not suggested any workarounds, just pointed out that default file storage is less "restrictive" :). Actually, that's why I had not noticed a bug in code that downloads facebook profile picture and saves it to django user's ImageField. I think an option (e. g. in django settings) like "disable seek" set to |
This fixes issue jschneier#860.
Also add tests to verify the behavior. This fixes issue jschneier#860.
Resolved by #1057 |
* Seek content to zero only once, before compressing * Only seek in S3Boto3Storage._save if content is seekable Also add tests to verify the behavior. This fixes issue #860.
) * Seek content to zero only once, before compressing * Only seek in S3Boto3Storage._save if content is seekable Also add tests to verify the behavior. This fixes issue jschneier#860.
I have a large (1gb or so) csv file that I want admin users to be able to upload that will then be processed by an offline task. Unfortunately, uploading that file to Django isn't straightforward - because Nginx has reasonable limits to prevent bad users from uploading massive files.
Long story short, I want users to be able to provide a link (dropbox, google drive, etc) which will then be streamed by django to S3 via django-storages.
Turns out that's not so difficult because the underlying stream of urllib3 provides a file-like interface. The following almost works:
But these streams are not files and do not support seek, which the s3boto3 backend attempts to do without question:
django-storages/storages/backends/s3boto3.py
Lines 545 to 546 in d827841
What it should do (I think..) is:
I've hacked my way around this by implementing seek and no-op the default case of seek(0) when already at the start of the file. Entire class provided for any interested onlookers.
The text was updated successfully, but these errors were encountered: