我能够生成 SAS 令牌
import { generateBlobSASQueryParameters } from '@azure/storage-blob';
function generateUploadUrl(){
const startsOn = new Date();
const expiresOn = new Date(startsOn.valueOf() + 60 * 60 * 1000);
const userDelegationKey = await this.blobServiceClient.getUserDelegationKey(startsOn, expiresOn);
const queryParams = generateBlobSASQueryParameters({ // HERE
containerName
permissions: BlobSASPermissions.parse('racwd'),
startsOn,
expiresOn,
}, userDelegationKey, this.storageAccount);
const token = queryParams.toString();
return `https://${this.storageAccount}.blob.core.windows.net/${this.containerName}/?${token}`;
}
并且感谢我能够使用此链接上传文件:
import { ContainerClient } from '@azure/storage-blob';
function uploadFile(localFilePath: string){
const containerClient = new ContainerClient(generatedUrl);
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
await blockBlobClient.uploadFile(localFilePath);
}
现在,文件上传完成后,我想撤销 SAS token,不允许进一步上传到 blob。我怎么能做到这一点?我找不到任何关于此的示例/信息。