Search code examples
pythongoogle-cloud-storagegoogle-cloud-python

Upload python object to Google Cloud Storage without saving it to file


I am clipping images in Python 2.7 on Windows 10 and would like to send them to Google's Cloud Vision API. For images saved locally, I can send them using the google.cloud python module like this:

                blob.upload_from_filename(filename=path)                        

Documented here

I would rather not save each crop to file, just to send the numpy arrays directly. I could change the numpy arrays to str objects and use

blob.upload_from_string()

but then Cloud Vision API would not be able to read them in my bucket. Is there any way to pipe from python to cloud storage bucket without wasting time/space saving them as an intermediate temporary object?


Solution

  • Unfortunately there is not. I am sorry!