Я пытаюсь загрузить файл в мое хранилище. Я использую этот кодПространство хранения облачных хранилищ Google
String serviceAccountEmail = "YOUR SERVICE EMAIL HERE";
var certificate = new X509Certificate2(@"PATH TO YOUR p12 FILE HERE", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { Google.Apis.Storage.v1.StorageService.Scope.DevstorageFullControl }
}.FromCertificate(certificate));
Google.Apis.Storage.v1.StorageService ss = new Google.Apis.Storage.v1.StorageService(new Google.Apis.Services.BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "YOUR APPLICATION NAME HERE",
});
var fileobj = new Google.Apis.Storage.v1.Data.Object()
{
Bucket = "YOUR BUCKET NAME HERE",
Name = "file"
};
Stream stream = null;
stream = new MemoryStream(img);
Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload insmedia;
insmedia = new Google.Apis.Storage.v1.ObjectsResource.InsertMediaUpload(ss, fileobj, "YOUR BUCKET NAME HERE", stream, "image/jpeg");
insmedia.Upload();
Я сделал новый проект -> консольное приложение (C#) и у меня есть проблемы со ссылками, я думаю, потому что я получаю эти ошибки:
The type or namespace name 'Storage' does not exist in the namespace 'Google.Apis' (are you missing an assembly reference?)
Мои usings:
using Google.Apis.Auth.OAuth2;
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
Что я делаю неправильно? Пожалуйста, помогите мне :)
' используя Google.Apis.Storage'? –
Нет такого метода – Icet