如何通过我在 Google App Engine 中的应用程序将文件写入 Google 云存储?
How do I write a file through my app in the Google App Engine to the Google Cloud Storage?
我正在寻找一种非常简单的方法来创建一个文件并通过我 运行 Google 应用引擎。为此,我需要在我的代码中使用哪个 libraries/functions?我用谷歌搜索了这个废话,但没有找到任何简单的方法。
我是编码新手,如果您提供代码示例,我将不胜感激!提前致谢:)
详情:
在该应用程序中,每当用户想要在另一个网站上搜索内容时,我都会在另一个网站上抓取 250 个网页。这当然会在服务器上产生极重的负载,更不用说用户必须等待长达 45 秒才能看到结果。为了解决这个问题,我想我应该设置一个 cron 作业,每隔 5 分钟左右抓取一次这些网页,并将它们的内容存储在某个文件中(最好是 250 个不同的文件),稍后应用程序会在搜索过程中访问这些文件查询。
使用这个库:https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/functions
所以像这样
import cloudstorage
with cloudstorage.open('/---bucket-name---/path/within/bucket/file.html', 'w') as f:
f.write(content)
我正在寻找一种非常简单的方法来创建一个文件并通过我 运行 Google 应用引擎。为此,我需要在我的代码中使用哪个 libraries/functions?我用谷歌搜索了这个废话,但没有找到任何简单的方法。
我是编码新手,如果您提供代码示例,我将不胜感激!提前致谢:)
详情: 在该应用程序中,每当用户想要在另一个网站上搜索内容时,我都会在另一个网站上抓取 250 个网页。这当然会在服务器上产生极重的负载,更不用说用户必须等待长达 45 秒才能看到结果。为了解决这个问题,我想我应该设置一个 cron 作业,每隔 5 分钟左右抓取一次这些网页,并将它们的内容存储在某个文件中(最好是 250 个不同的文件),稍后应用程序会在搜索过程中访问这些文件查询。
使用这个库:https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/functions
所以像这样
import cloudstorage
with cloudstorage.open('/---bucket-name---/path/within/bucket/file.html', 'w') as f:
f.write(content)