-
Notifications
You must be signed in to change notification settings - Fork 47
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 passing files not at beginning to 'ResumableUpload' #165
Comments
whoa, ten-thousandth issue! |
I second this, it would be nice if we don't need wrapper around unseekable file-like object to make it work with The |
Hi all, I arrived here because I was struggling to upload an image transformed using PIL to do a reduction in size. Was trying in the same way you did to upload an object from "bytes" type. I hope this is the way I should participate in an issue like this one, by providing a fix that worked for me in my particular case. And would have helped me in the first place when I reached the issue. From the issue snippet provided by @retnikt :
I've just changed the last line using the
Hope it helps other people reaching this issue for the same reason I did, apologies if is not the way to do it. |
@vperezb the issue with this is, if the file-like object is a stream rather than in memory, e.g. network or disk, then using a string requires loading all the data into memory. |
It is possible that some combination of stream-not-at-start, a passed |
Thank you, worked for me |
Environment details
Ubuntu, Python 3.7, Google Cloud Storage 1.23.0
Steps to reproduce
blob.upload_from_file(fp)
wherefp
is not at the beginning of the stream (i.e. it has been sought)Code example
Traceback
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.The text was updated successfully, but these errors were encountered: