我能够创建容器、列表容器、列表Blob但当我试图做一个PUT/DELETE
请求upload or deleteAzure 存储 blob 中的文件,但发出请求后显示以下错误:
403
This request is not authorized to perform this operation using this permission.
{
'content-length': '279',
'content-type': 'application/xml',
server: 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0',
'x-ms-request-id': '4de6c154-f01e-0051-7ce4-1314ef000000',
'x-ms-version': '2018-03-28',
'x-ms-error-code': 'AuthorizationPermissionMismatch',
date: 'Mon, 08 Mar 2021 06:32:44 GMT',
connection: 'close'
}
代码为upload/PUT
文件是:
const request = require("request");
require("dotenv").config();
const account = process.env.ACCOUNT_NAME || "";
const containerName = "demo";
const blobName = "dummyfile1.txt";
const blobContent = "Hello, This will be written in file";
const contentLength = new TextEncoder().encode(blobContent).length;
var strTime = new Date().toUTCString();
const options = {
url: `https://${account}.blob.core.windows.net/${containerName}/${blobName}`,
headers: {
Authorization: "Bearer <BearerToken>",
"x-ms-date": strTime,
"x-ms-version": "2018-03-28",
"x-ms-blob-type": "BlockBlob",
"Content-Length": contentLength,
"Content-Type": 'application/text-plain',
},
body: blobContent,
};
function callback(error, response, body) {
console.log(response.statusCode);
console.log(response.statusMessage);
console.log(response.headers);
}
request.put(options, callback);
在这里,我手动替换我通过 POSTMAN 获取的内容:
另外,我还给App添加了Storage Data Contributor的权限:
I have delegated Azure Storage, user_impersonation permission also to the Application.
但同样的错误仍然存在。