【发布时间】:2014-11-22 04:56:19
【问题描述】:
我正在尝试通过 C# API 将简单图像上传到 Google 云存储。它似乎成功了,但我在我的 Google 云存储桶中看不到任何内容。
我目前的代码:
Google.Apis.Services.BaseClientService.Initializer init = new Google.Apis.Services.BaseClientService.Initializer();
init.ApiKey = "@@myapikey@@";
init.ApplicationName = "@@myapplicationname@@";
Google.Apis.Storage.v1.StorageService ss = new Google.Apis.Storage.v1.StorageService(init);
var fileobj = new Google.Apis.Storage.v1.Data.Object()
{
Bucket = "images",
Name = "some-file-" + new Random().Next(1, 666)
};
Stream stream = null;
stream = new MemoryStream(img);
Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload insmedia;
insmedia = new Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload(ss, fileobj, "images", stream, "image/jpeg");
insmedia.Upload();
response.message = img.Length.ToString();
【问题讨论】:
标签: c# google-api google-cloud-storage google-api-dotnet-client