Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cloud 谷歌云存储删除目录_Cloud_Storage - Fatal编程技术网

Cloud 谷歌云存储删除目录

Cloud 谷歌云存储删除目录,cloud,storage,Cloud,Storage,嗨,我试图在谷歌云存储中删除一个完整的存储库,但在API中没有找到任何关于它的内容。 删除单个文件没有问题 @Autowired private Storage storage; @RequestMapping(value = "/", method = RequestMethod.GET) public String deleteGcsFile() throws IOException { String location = "gs://myPath/my-file.txt";

嗨,我试图在谷歌云存储中删除一个完整的存储库,但在API中没有找到任何关于它的内容。 删除单个文件没有问题

@Autowired
private Storage storage;

@RequestMapping(value = "/", method = RequestMethod.GET)
public String deleteGcsFile() throws IOException {

    String location = "gs://myPath/my-file.txt";
    GoogleStorageResourceObject gcsFile = new GoogleStorageResourceObject(StorageOptions.getDefaultInstance().getService(), location);

    storage.delete(gcsFile.getGoogleStorageObject().getBlobId());

    return "ok";
}

在云中,您可以使用以下功能删除目录:

import { storage } from 'firebase-admin'; //Import storage

const deleteAppletImage = (directory) => {
  const bucket = storage().bucket();
  return bucket.deleteFiles({
    prefix: directory,
  });
};
请注意,目录(函数参数)应该是一个字符串,表示bucket中目录的完整路径。如果目录是根目录,它可以是一个简单的目录名,例如“images”

还要注意,我没有向
bucket()
提供任何参数。这样,操作将使用默认的bucket,但您可以指定要作为目标的bucket,如下所示:
const bucket=storage().bucket('target-bucket')

bucket()
公开了与google云存储包相同的API。您可以在此查看有关使用google云存储API删除多个文件的更多信息