1
我想通過C#API將簡單圖片上傳到Google雲端存儲。它似乎成功了,但我沒有看到我的Google雲存儲桶中有任何東西。Google雲端存儲上傳不適用於C#API
的代碼,我到目前爲止有:
Google.Apis.Services.BaseClientService.Initializer init = new Google.Apis.Services.BaseClientService.Initializer();
init.ApiKey = "@@[email protected]@";
init.ApplicationName = "@@[email protected]@";
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();
創建服務帳戶在阿比和驗證您的開發人員控制檯 - >憑證 – Saumil 2014-11-22 18:55:33