python - 如何使用 python 将原始 json 数据 [as pyhon Dictionary] 写入谷歌云存储?
问题描述
我的用例非常简单,我从我的 REST API 中获取原始 JSON 响应并将其保存为 python 中的字典,我必须将此数据写入谷歌云存储。除了“upload_from_string”选项之外还有其他方法吗?
解决方案
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.
推荐阅读
- python - “列表索引必须是整数或切片,而不是 str”试图读取 json
- flutter - 在 Flutter 中实现卡片翻转动画
- html - 基于真假在同一个模板中应用CSS类的最佳方式
- powershell - Powershell更改所有文件夹和子文件夹中快捷方式的路径
- javascript - 如何在javascript中对对象的总和数组进行分组?
- xamarin.forms - Xamarin 在框架内形成导航
- javascript - 如何在 reactjs 中创建一个异步函数,该函数从 redux 操作中调用另外两个函数
- java - 在 spring 提供的这么多事件中 - 哪个事件是正确的事件来监听我的应用程序的数据缓存
- asp.net - 数据表 asp.net 的最后一行
- html - 基于最宽标签对齐表单输入元素的 CSS 方式