Solution 1: gcsfs
gcsfs is a 3rd party library (not by Google)
import gcsfsfs = gcsfs.GCSFileSystem(token='keys/travelopyz-appengine.json')BUCKET_NAME = '...'filename = f"{BUCKET_NAME}/DIRECTORY_NAME/test_file.txt"# with gcsfs.core.GCSFile(fs, f'travelopyz.appspot.com/generate/get_items_test/test_file4', 'wb', acl='publicread', consistency='none', block_size=5242880) as f:with fs.open(filename, 'wb', acl='publicread') as f: f.write('Item 1'.encode()) f.write('Item 2'.encode())
NOTE: acl - publicread
doesn't seems to work, checking the source code would note that the acl args
is not used. I tried using GCSFile
and acl doesn't seems to work as well.
Solution 2: google-resumable-media
I have yet to try this, but following are some relevant resources.
- https://googleapis.github.io/google-resumable-media-python/latest/google.resumable_media.requests.html#resumable-uploads
- https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload
- https://dev.to/sethmichaellarson/python-data-streaming-to-google-cloud-storage-with-resumable-uploads-458h
Solution 3: google-cloud-storage
There is a request issue raised.
The source code has some hint/potential for resumable multipart upload.