-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
api: storageIssues related to the googleapis/google-resumable-media-python API.Issues related to the googleapis/google-resumable-media-python API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
Environment details
Ubuntu, Python 3.7, Google Cloud Storage 1.23.0
Steps to reproduce
- Create a Blob
- Use
blob.upload_from_file(fp)wherefpis not at the beginning of the stream (i.e. it has been sought)
Code example
from google.cloud import storage
client = storage.Client()
bucket = client.bucket("somebucket")
blob = bucket.blob("path/to/blob.txt")
fp = io.BytesIO(b'\0' * 100)
fp.seek(40)
blob.upload_from_file(fp)Traceback
Traceback (most recent call last):
...
File "/.../google/cloud/storage/blob.py", line 1262, in upload_from_file
created_json = self._do_upload(
File "/.../google/cloud/storage/blob.py", line 1172, in _do_upload
response = self._do_resumable_upload(
File ".../google/cloud/storage/blob.py", line 1110, in _do_resumable_upload
upload, transport = self._initiate_resumable_upload(
File "/.../google/cloud/storage/blob.py", line 1059, in _initiate_resumable_upload
upload.initiate(
File "/.../google/resumable_media/requests/upload.py", line 338, in initiate
method, url, payload, headers = self._prepare_initiate_request(
File "/.../google/resumable_media/_upload.py", line 415, in _prepare_initiate_request
raise ValueError(u"Stream must be at beginning.")
ValueError: Stream must be at beginning.
Description
I cannot see any reason why there is the check if stream.tell() != 0. It seems to serve only to frustrate users trying to upload from custom unseekable file-like objects (e.g. googleapis/google-cloud-python#7282), or only parts of files. Can this not be removed, or moved to somewhere else more relevant in the codebase if it serves a purpose only thence.
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/google-resumable-media-python API.Issues related to the googleapis/google-resumable-media-python API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.