我正在尝试生成一个 blob 版本的 SAS 以允许对一个特定版本的 blob 进行读取访问。我让 SAS 生成为根 blob 工作,并尝试通过添加 BlobVersionId 为 blob 版本控制功能修改它,但是服务器返回 403。
针对特定 blob 版本修改了 SAS Builder:(不工作)
public string GetBlobSasTokenAsync(string containerName, string blobName, string blobVersionId, string fileName)
{
var sasBuilder = new BlobSasBuilder()
{
BlobContainerName = containerName,
BlobName = blobName,
BlobVersionId = blobVersionId,
StartsOn = DateTime.UtcNow.Subtract(_clockSlew),
ExpiresOn = DateTime.UtcNow.AddMinutes(AccessDuration) + _clockSlew,
ContentDisposition = "inline; filename=" + fileName,
ContentType = GetContentType(fileName)
};
sasBuilder.SetPermissions("r");
var storageSharedKeyCredential = new StorageSharedKeyCredential(_accountName, _accountKey);
var sasQueryParameters = sasBuilder.ToSasQueryParameters(storageSharedKeyCredential);
return sasQueryParameters.ToString();
}
错误:
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:63b83bb8-201e-00a8-55a1-544fe3000000
Time:2020-07-07T21:01:08.2149986Z</Message>
<AuthenticationErrorDetail>The specified signed resource is not allowed for the this resource level</AuthenticationErrorDetail>
</Error>
使用: Azure.Storage.Blobs 12.5.0-preview.5