使用Node.js GCloud API删除Google Cloud Storage中的文件夹 [英] Delete folder in Google Cloud Storage using nodejs gcloud api

查看:87
本文介绍了使用Node.js GCloud API删除Google Cloud Storage中的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用gcloud nodejs api访问Google Cloud Storage.我可以分别保存/删除/存在文件,但找不到使用gcloud nodejs api删除文件夹甚至列出文件夹中文件的方法.

I am using gcloud nodejs api to access Google Cloud Storage. I can save/delete/exists files individually, but I didn't find a way to delete a folder or even to list the files in a folder using gcloud nodejs api.

我已经看到人们说GCS中的文件夹层次结构不是真正的树结构,而只是名称.因此,我尝试使用通配符来匹配文件名字符串,但失败了.

I have seen people say that the folder hierachy in GCS is not a real tree structure, but just names. So I tried to use wildcard to match the file name string, which did not succeed.

我想知道是否有任何方法可以做到这一点.如果没有,我应该使用什么工具?

I wonder if there is any way to do it. If not, what tool should I use?

推荐答案

列出目录中文件的代码应如下所示:

The code to list files in a directory should look something like this:

bucket.getFiles({ prefix: 'directoryName/' }, function(err, files) {})

并删除:

bucket.deleteFiles({ prefix: 'directoryName/' }, function(err) {})

  • getFiles API文档
  • deleteFiles API文档
    • getFiles API documentation
    • deleteFiles API documentation
    • 这篇关于使用Node.js GCloud API删除Google Cloud Storage中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆