繁体   English   中英

如何使用客户端库从节点 js 上传文件夹到 GCS

[英]How to upload folders to GCS from node js using client library

要将文件从节点上传到 google-cloud-storage (gcs),有记录的过程,例如

const Storage = require('@google-cloud/storage');
const storage = new Storage();
{
const bucket = storage.bucket("bt-name");
const res = await bucket.upload("./output_images/dir/file.png", {
            public: true
        });
}

但是我想将整个目录上传到bt-name 中的gcs ,当我尝试这样做时,它会抛出承诺拒绝错误 - EISDIR:对目录进行非法操作,请阅读

使用 API 或客户端库上传整个文件夹不是内置功能。 如果您想上传整个文件夹,则需要您的代码循环遍历所有文件夹文件并一次上传所有文件夹,或者您可以使用命令行实用程序gsutil的递归上传选项.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM