本文介绍了创建文件夹Google Cloud Storage Bucket .NET客户端库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用以下客户端库在存储桶内创建文件夹的方法: https://cloud.google.com/storage/docs/json_api/v1/json-api-dotnet-samples

I'm looking to at a way to create a folder inside a bucket using the following client library:https://cloud.google.com/storage/docs/json_api/v1/json-api-dotnet-samples

我看了下面的线程,看来我需要使用简单的方法上载.使用php在存储桶Google云存储中创建文件夹

I've looked at the following thread, and it appears I need to use the simple method upload.Creating folder in bucket google cloud storage using php

我看不到能够指定uploadtype的任何方式,所有请求似乎都是uploadType=resumable.

I can't see any way of being able to specify a uploadtype, all requests appear to be uploadType=resumable.

看上面的文章和提琴手的痕迹,我需要使用uploadType=media.有没有办法做到这一点?

Looking at the above post and a fiddler trace I need to use uploadType=media. Is there away to accomplish this?

推荐答案

在最新版本的API中进行此操作比较简单.您仍然必须确保按照塞勒姆的建议检查"/".

It is a bit more straighforward to do this in the latest version of the API.You still have to make sure that you check for the "/" as Salem has suggested.

     public void AddFolder(string folder)
        {
           StorageClient storageClient = StorageClient.Create();
           if (!FolderName.EndsWith("/"))
             FolderName += "/";

          var content = Encoding.UTF8.GetBytes("");

           storageClient.UploadObject(bucketName, folder, "application/x-directory", new MemoryStream(content));

        }

这篇关于创建文件夹Google Cloud Storage Bucket .NET客户端库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:12