我使用谷歌云存储 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();
没关系。但我不能使用版本号。
这是没有签名网址的正常下载;我在签名网址上寻找“IfGenerationMatch =”
await client.DownloadObjectAsync(
bucket: bucketName,
objectName: sourcePath,
destination: destinationPath,
progress: progress,
options: new DownloadObjectOptions()
{ ChunkSize = 1048576, Range = rangeHeaderValue, IfGenerationMatch = data.GenerationNo }
);