问题描述
我使用 Google Cloud Storage API。我像这样创建签名网址;
var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer("username@iam.gserviceaccount.com").FromPrivateKey(PrivateKey));
var urlSigner = UrlSigner.FromServiceAccountCredential(credential);
string url = urlSigner.Sign(bucketName,"Sample.txt",TimeSpan.FromDays(7));
var httpClient = new System.Net.Http.HttpClient();
System.Net.Http.HttpResponseMessage response = await httpClient.GetAsync(url);
var content = await response.Content.ReadAsByteArrayAsync();
没关系。但我不能为版本使用第 1 代。
这是没有签名网址的正常下载; 我在签名网址上寻找“IfGenerationMatch =”
await client.DownloadobjectAsync(
bucket: bucketName,objectName: sourcePath,destination: destinationPath,progress: progress,options: new DownloadobjectOptions()
{ ChunkSize = 1048576,Range = rangeHeaderValue,IfGenerationMatch = data.GenerationNo }
);