我想要使用蓝色文件存储图像文件。
我可以用下面的代码上传图像文件
...
const uploadBlobResponse = await blockBlobClient.uploadFile('./test.png');
console.log('Blob was uploaded successfully. requestId: ', uploadBlobResponse);输出是
Blob was uploaded successfully. requestId: {
etag: '"0x8D8FCCEC050FDB7"',
lastModified: 2021-04-11T09:46:59.000Z,
contentMD5: <Buffer a6 c1 b2 ef 44 0d 59 d2 33 43 ea c3 03 06 3f e3>,
clientRequestId: 'c261dccb-1b2f-4802-9768-c98bb59cc8b4',
requestId: '686eda5f-301e-00c0-49b7-2ead12000000',
version: '2020-06-12',
versionId: undefined,
date: 2021-04-11T09:46:58.000Z,
isServerEncrypted: true,
encryptionKeySha256: undefined,
encryptionScope: undefined,
errorCode: undefined,
'content-length': '0',
server: 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0',
'x-ms-content-crc64': 'F99Vk4U+TkE=',
body: undefined
}因此,我无法获得图像的公共URL。
我怎么能这么做?
发布于 2021-04-11 11:06:38
BlockBlobClient有一个url属性,它将为您提供blob的URL。类似于:
const uploadBlobResponse = await blockBlobClient.uploadFile('./test.png');
console.log('Blob was uploaded successfully. requestId: ', uploadBlobResponse);
console.log('Blob URL: ', blockBlobClient.url);但是,即使URL是blob的公共URL,如果blob位于具有404 (Not Found) ACL的blob容器中,它仍然可能导致Private错误。您需要使用具有至少Shared Access Signature权限的blob的Read URL才能按其URL查看blob。
https://stackoverflow.com/questions/67043541
复制相似问题