gpt4 book ai didi

node.js - 哈希与 Azure Blob 存储不匹配(完整性检查失败)

转载 作者:搜寻专家 更新时间:2023-11-01 00:23:56 25 4
gpt4 key购买 nike

我正在关注http://willi.am/blog/2014/07/03/azure-blob-storage-and-node-downloading-blobs/ .

然而,尽管代码完全相同,当我下载 blob Azure 时却出现错误:

[错误:哈希不匹配(完整性检查失败),预期值为...]

正在运行的行是 blobService.getBlobToText,其中 blobService 是与 Azure 的连接(createBlobService...)

发生什么事了? :S

我的代码如下:

    // Azure test
function downloadImageAsText(blobService, containerName, blobName) {

blobService.getBlobToText(
containerName,
blobName,
function(err, blobContent, blob) {
if (err) {
console.error("Couldn't download blob %s", blobName);
console.error(err);
} else {
console.log("Sucessfully downloaded blob %s", blobName);
console.log(blobContent);
}
});

}

function uploadImage(blobService, containerName, blobName, fileName) {

blobService.getBlobProperties(
containerName,
blobName,
function(err, properties, status) {
if (status.isSuccessful) {
// Blob exists
} else {
blobService.createBlockBlobFromLocalFile(
containerName,
blobName,
fileName,
function(error, result, response){
if(error){
console.log("Couldn't upload file %s", fileName);
console.error(error);
} else {
console.log('File %s uploaded successfully', fileName);
downloadImageAsText(blobService, containerName, blobName);
}
});
}
});
}


function testAzure() {

accountName / hash = my details

var storage = require('azure-storage');
var blobService = storage.createBlobService(accountName, hash);
var containerName = 'tst';
var blobName = 'test.png';
var fileName = 'test.png';

blobService.createContainerIfNotExists(containerName, function(err, result, response) {
if (err) {
console.log("Couldn't create container %s", containerName);
console.error(err);
} else {
if (result) {
console.log('Container %s created', containerName);
uploadImage(blobService, containerName, blobName, fileName);
} else {
console.log('Container %s already exists', containerName);
uploadImage(blobService, containerName, blobName, fileName);
}
}
});
}

function startServer() {
http = require('http');
const PORT = 8080;
var server = http.createServer(handleRequest);
server.on('listening',function(){
console.log("Server listening on: http://178.62.117.207:%s", PORT);
});
server.listen(PORT);
}

startServer();
testAzure();

最佳答案

如果其他人遇到这种情况;当您存储 Buffer 对象但检索 string 时会发生这种情况。

关于node.js - 哈希与 Azure Blob 存储不匹配(完整性检查失败),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30609691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com