如果您能帮我解决我的示例中的透明度问题,我将非常感激:http://jsfiddle.net/Mihails/oL0uwtvs/2
private static IConfigurableHttpClientInitializer GetInstalledApplicationCredentials()
{
string serviceAccountEmail = "xxxxxxxx";
X509Certificate2 certificate;
using (Stream stream = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "path.p12"), FileMode.Open, FileAccess.Read))
{
using (MemoryStream ms = new MemoryStream())
{
stream.CopyTo(ms);
certificate = new X509Certificate2(ms.ToArray(), "notasecret", X509KeyStorageFlags.Exportable);
}
}
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] {
StorageService.Scope.DevstorageFullControl
},
}.FromCertificate(certificate));
return credential;
}
private static StorageService GetStoreageService()
{
var service = new StorageService(
new BaseClientService.Initializer()
{
HttpClientInitializer = GetInstalledApplicationCredentials(),
ApplicationName = "app"
}
);
return service;
}
public static byte[] DownloadAudio(string fileName)
{
var service = GetStoreageService();
var req = service.Objects.Get(bucketName, fileName);
var readobj = req.Execute();
var downloader = new MediaDownloader(service);
using (var ms = new MemoryStream())
{
downloader.Download(readobj.MediaLink, ms);
return ms.ToArray();
}
}
请参阅:Issue details
主要挑战:
非常感谢和最诚挚的问候,