Have a python code running on cloud function using cloud function python.
I'm processing an image on cloud. Now I want to save that image on google-cloud-storage
from google.cloud import storage
import cv2
from tempfile import NamedTemporaryFile
import os
client = storage.Client()
bucket = client.get_bucket('document')
image = cv2.imread('15.png')
with NamedTemporaryFile() as temp:
print(type(temp.name)," ",temp.name)
iName = "".join([str(temp.name),".jpg"])
print(iName)
cv2.imwrite(iName,image)
print(os.path.exists(str(iName)))
blob = bucket.blob('document/Test15.jpg')
blob.upload_from_filename(iName)
My output
< class 'str' >
/var/folders/5j/bqk11bqj4r55f8975mn__72m0000gq/T/tmplcgzaucx
/var/folders/5j/bqk11bqj4r55f8975mn__72m0000gq/T/tmplcgzaucx.jpg
True
Don't know what's going wrong
can anyone suggest a solution?
Silly mistake, turns out
blob = bucket.blob('document/Test15.jpg')
creates another folder
document
inside the bucketdocument
so the actual path would be
document/document/Test15.jpg