如何修复蔚蓝的斑点认证错误认证头/ Mac的签名犯规匹配
我使用Azure的Blob和上传图片作为斑点放入容器中,一切工作昨天,但由于某种原因,今天,当我试图创建BLOB(上传图片),我得到一个错误:
(node:5412) UnhandledPromiseRejectionWarning: Error: <?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:742c79aa-601e-0046-2f47-bd0f64000000
Time:2019-02-05T11:38:04.9687033Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'iEGyntz0xOL6HddnoD/F6GxkHjyZlxEGTQ21OjlWCy4=' is not the same as any computed signature. Server used following string to sign: 'PUT
67
application/xml; charset=utf-8
我创建容器已经和它的容器和数据访问有一套是怎么回事之前的工作。我拿回containerURL和blobURL仿佛一滴创建我找回集装箱网址:
并且我也得到了BlobURL:
".jpg"
但是当我在蔚蓝色的仪表板检查集装箱内的斑点是不存在的。
我也检查了我的时间,我是在UTC + 2,并将其转换为UTC 0等于我从服务器获取GMT,但它是在GMT + 2工作昨天也是如此。不知道为什么我收到此,一切都工作之前。
谢谢
更新1:
我把代码做上传到try catch块,我得到了这种格式的错误:
'<?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.\nRequestId:6b27b7c2-601e-0024-474c-bdcd43000000\nTime:2019-02-05T12:14:44.3155159Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request \'n/0RjbOhVCOHSkWlq4JWqPsgMe7UxkuyrA1HV1Y1AcY=\' is not the same as any computed signature. Server used following string to sign: \'PUT\n\n\n67\n\napplication/xml; charset=utf-8\n\n\n\n\n\n\nx-ms-client-request-id:ce83a49c-51fb-476e-b4ab-25968c162d82\nx-ms-date:Tue, 05 Feb 2019 12:14:43 GMT\nx-ms-version:2018-03-28\n/facerstorage/watchlist/CHRISTOPHER%20ROBERT%20METSOS.jpg\ncomp:blocklist\ntimeout:60000\'.</AuthenticationErrorDetail></Error>',
headers: HttpHeaders { _headersMap: [Object] },
status: 403 },
body:
{ message:
'Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:6b27b7c2-601e-0024-474c-bdcd43000000\nTime:2019-02-05T12:14:44.3155159Z' } }
这里是我的代码,做我从蔚蓝的SDK基础和修改它一点点上传:
async function uploadImage(aborter, containerURL, filePath, blobName) {
try{
filePath = path.resolve(filePath);
const blockBlobURL = BlockBlobURL.fromContainerURL(containerURL, blobName);
console.log("Blob created, URL is: " + JSON.stringify(blockBlobURL.url));
const stream = fs.createReadStream(filePath, {
highWaterMark: FOUR_MEGABYTES,
});
const uploadOptions = {
bufferSize: FOUR_MEGABYTES,
maxBuffers: 5,
};
//SAVE URL TO DB
addToDB(blobName, blockBlobURL.url);
return await uploadStreamToBlockBlob(
aborter,
stream,
blockBlobURL,
uploadOptions.bufferSize,
uploadOptions.maxBuffers);
} catch (err) {console.log(err)}
}
更新#2
-Checked Azure的按键和刷新他们和更换。
-able,使容器没有得到任何身份验证错误。
使用普通uploadLocalFile,而不是流得到的错误以及-Tried。
回答如下:发现错误,文件我是上载有名称之间的间隔例如“约翰·马库斯”
虽然我已经处理了这个使用:
fileName = fileName.replace(/\s/gi, '-')
前更换空间,我后来加入的一个类别的bloname创建一个虚拟目录和类别有空间,以便它/我的猫/文件名,这是在打破了它的类别名称的空间。
但在结束与替代空间 - 固定我的问题。
感谢所有帮助谁