1

我的用例非常简单,我从我的 REST API 中获取原始 JSON 响应并将其保存为 python 中的字典,我必须将此数据写入谷歌云存储。除了“upload_from_string”选项之外还有其他方法吗?

4

1 回答 1

2

For uploading data to Cloud Storage, you have only 3 methods in Python blobs object:

  • Blob.upload_from_file()
  • Blob.upload_from_filename()
  • Blob.upload_from_string()

From dict, it's up to you to choose to convert it into a string and use upload_from_string method. Or you can also store it locally, in the /tmp directory (in memory file system), and then use file purpose methods.

You maybe have more capabilities with files, if you want to zip the content and/or use dedicated library that dump a dict into a file.

于 2020-06-14T11:46:53.490 回答