Skip to content
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

Allow setting the chunk_size in Blob creation via the GS_BLOB_CHUNK_SIZE #401

Closed
wants to merge 3 commits into from

Conversation

joahim
Copy link

@joahim joahim commented Oct 4, 2017

When uploading a large file to the Google Cloud Storage, the generated request must fit into memory and can easily exhaust it. This can be avoided by specifying the chunk_size at Blob creation which then triggers the resumable upload that uploads the file in chunks and does not load the complete file into memory.

See: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/d3ef455b797b6960ed58f563d4b43d9dcc4c7364/storage/google/cloud/storage/blob.py#L770

…tting

When uploading a large file to the Google Cloud Storage, the generated request must fit into memory and can easily exhaust it. This can be avoided by specifying the chunk_size at Blob creation which then triggers the resumable upload that uploads the file in parts and does not load the complete file in memory.

See: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/d3ef455b797b6960ed58f563d4b43d9dcc4c7364/storage/google/cloud/storage/blob.py#L770
Allow setting the chunk_size in Blob creation via the GS_BLOB_CHUNK_SIZE
@codecov-io
Copy link

codecov-io commented Oct 5, 2017

Codecov Report

Merging #401 into master will decrease coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #401      +/-   ##
==========================================
- Coverage    76.1%   76.05%   -0.06%     
==========================================
  Files          11       11              
  Lines        1578     1566      -12     
==========================================
- Hits         1201     1191      -10     
+ Misses        377      375       -2
Impacted Files Coverage Δ
storages/backends/gcloud.py 95.7% <100%> (+0.9%) ⬆️
storages/backends/s3boto.py 87.41% <0%> (-0.05%) ⬇️
storages/backends/s3boto3.py 86.54% <0%> (-0.05%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea5649f...ff84614. Read the comment docs.

@myimages
Copy link

myimages commented Oct 5, 2017

I think this cloud be very easily done with simple python inheritance.

I have approached the same problem by creating custom_storages.py in my app and overriding the GoogleCloudFile init method.

and in my new storage class PublicImageUploadStorage , I have overridden the _save method to use my new ChunkedGoogleCloudFile class since it is the only method that has the w write flag.

sooner or later , you will end up overriding the class to add your own customization ( setting metadata , changing default acl, bucket name , upload files directly without saving them locally , etc ) , so it is better done now.

@joahim
Copy link
Author

joahim commented Oct 5, 2017

@myimages I am already subclassing storages.backends.gcloud.GoogleCloudStorage to have additional methods from the GoogleStorage available. However, chunked uploads are in my opinion often required (also, Google suggest this method for all Blobs bigger than 5MB) and should therefore be available out of the box.

@dummerbd
Copy link

I think this should definitely be included in this lib instead of requiring people to subclass both GoogleCloudFile and GoogleCloudStorage and then overriding both the _open and _save methods to use your file subclass. Its a lot of effort just to set something that should probably be set to a reasonable default (like 5MB).

@sww314 sww314 added the google label Jul 11, 2018
@sww314
Copy link
Contributor

sww314 commented Jul 11, 2018

@joahim Can you add documentation for this setting?

@jschneier
Copy link
Owner

Added docs in #757.

@jschneier jschneier closed this Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants