-
-
Notifications
You must be signed in to change notification settings - Fork 865
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
Amazon S3: can't get file chunk without loading whole file into memory #383
Comments
I'm having the same trouble. I'm trying to download a 2.6 GB file with the following code but the open() call tries to read the entire file and is getting a timeout. Seems that get()['Body'] is already using a StreamingBody and it saves to a SpooledTemporaryFile. But it is doing it in a single write which means it never gets a chance to switch from BytesIO to TemporaryFile. See PR below for fix. AWS_S3_MAX_MEMORY_SIZE must be set in settings before S3Boto3Storage is imported. |
@jeffcjohnson nice catch. I will leave this traceback here for those googling for solution
|
For those who've come across this issue and don't want to wait for the PR to be merged, checkout |
We faced a problem of very slow uploads, switching to django-s3-storage helped. Probably caused by the fact that our s3 instance was not in the same region like our server |
Example:
causes MemoryError to me, because it try to load ~5GB file.
It's because in a
S3Boto3StorageFile._get_file
method the whole file is loaded into memory every time we request it:But boto3 supports reading file by chunk:
the only way to workaround is:
but it's not generic anymore.
The text was updated successfully, but these errors were encountered: