相关疑难解决方法(0)

如何通过Python脚本在Google Cloud Storage上上传字节图像

我想通过python脚本在Google Cloud Storage上上传图像。这是我的代码:

from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient import discovery

scopes = ['https://www.googleapis.com/auth/devstorage.full_control']
credentials = ServiceAccountCredentials.from_json_keyfile_name('serviceAccount.json', scop
es)
service = discovery.build('storage','v1',credentials = credentials)

body = {'name':'my_image.jpg'}

req = service.objects().insert(
   bucket='my_bucket', body=body,
   media_body=googleapiclient.http.MediaIoBaseUpload(
      gcs_image, 'application/octet-stream'))

resp = req.execute()
Run Code Online (Sandbox Code Playgroud)

如果gcs_image = open('img.jpg', 'r')代码有效并且可以将我的映像正确保存在Cloud Storage中。如何直接上传字节图像?(例如,从一个的OpenCV / numpy的数组:gcs_image = cv2.imread('img.jpg')

python opencv google-cloud-storage google-cloud-platform

5
推荐指数
3
解决办法
2182
查看次数

如何使用Google App Engine将图像上传到Google云端存储?

我正试图找出一种使用Google App Engine将图像上传到Google云端存储的方法.

我检查过:

使用谷歌应用引擎将图像发送到谷歌云存储

使用Google App Engine将图像/视频上传到Google云存储

他们都展示了如何使用BlobStore API来完成它.

当我检查BlobStore API时:https://cloud.google.com/appengine/docs/python/blobstore/

他们提供了使用Google云端存储的说明.BlobStore的当前状态是什么,未来是否会得到支持?

我看到了图像上传的示例:https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/blobstore/main.py使用BlobStore API.

是否有使用Google App Engine的Google云端存储示例?

python google-app-engine google-cloud-storage

3
推荐指数
2
解决办法
3879
查看次数