使用cloud function python在云端函数上运行python代码。
我在云上处理图片。现在我想将该图像保存在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)
我的输出
< class' str' >
的/ var /文件夹/ 5J / bqk11bqj4r55f8975mn__72m0000gq / T / tmplcgzaucx
/var/folders/5j/bqk11bqj4r55f8975mn__72m0000gq/T/tmplcgzaucx.jpg
真
不知道出了什么问题
有人可以提出解决方案吗?
答案 0 :(得分:0)
愚蠢的错误,结果
if (context.User.CanImpersonate()) context.Succeed(requirement);
在广告素材blob = bucket.blob('document/Test15.jpg')
document
因此实际路径为document