No error: could not view the downloaded file in Google Cloud Storage

I have python code running on a cloud function using a python cloud function .

I process the image in the cloud. Now I want to save this image togoogle-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 conclusion

<class 'str'>

/ var / folders / 5j / bqk11bqj4r55f8975mn__72m0000gq / / tmplcgzaucx

/var/folders/5j/bqk11bqj4r55f8975mn__72m0000gq/T/tmplcgzaucx.jpg

True

I don’t know what will go wrong.

can anyone suggest a solution?

0
source share
1 answer

Stupid mistake, it turns out

blob = bucket.blob('document/Test15.jpg')

document document

document/document/Test15.jpg

0

Source: https://habr.com/ru/post/1685163/


All Articles