【问题标题】:CSV Array directly to Google Cloud StorageCSV 数组直接到 Google Cloud Storage
【发布时间】:2018-11-18 20:32:40
【问题描述】:

我目前有一个脚本,可以在本地保存一个 csv 文件,然后将其上传到 Google Cloud 存储。

我希望将此应用程序迁移到 Google App Engine,但是我知道您无法将文件直接写入本地文件系统,这需要直接写入 Google Cloud 存储。

说实话,我不确定如何将 csv 数据直接传递给上传。

我应该使用任何读写流吗?

非常感谢任何帮助。

【问题讨论】:

标签: javascript node.js google-app-engine google-cloud-platform google-cloud-storage


【解决方案1】:

你说得对。使用 App Engine Standard 时无法写入磁盘,但在柔性环境中,you can!

此外,由于您已使用 node.js 标记标记此问题,我假设您的代码是用该语言编写的。更好的是,如果您想在 App Engine 中使用它,you must use Flexible,因为 node.js 不能在 App Engine Standard 上运行。

因此,您可以轻松将此代码移至 App Engine Flexible。

您也可以将此代码移至 Cloud Functions,但您只能在 /tmp 目录中的函数实例中写入临时文件。请注意,它将消耗为该功能提供的内存资源。

您应该能够继续使用您已有的代码,只需修改写入临时文件的位置(如果您使用 Cloud Functions)。

编辑

当我写这篇文章时,Node 仅在 Flexible 中可用,但现在不再是这样了:在 App Engine Standard 中输入 Node.js。

但是,这不会改变您的情况:您仍然无法在使用 Standard 时写入磁盘,因此,Flexible 或 Cloud Functions 是您的最佳选择。

【讨论】:

    猜你喜欢
    • 2020-01-15
    • 2014-02-21
    • 2018-01-28
    • 2020-01-07
    • 1970-01-01
    • 1970-01-01
    • 2018-11-27
    • 2019-12-08
    • 2019-07-11
    相关资源
    最近更新 更多