使用 nodejs 在 azure blob 上设置 content-md5?

Setting content-md5 on azure blob with nodejs?

我用nodejs上传了一个文件

 sharedBlobSvc.createBlockBlobFromLocalFile(containerName, blobName, path, function (error, result, response) {
                    grunt.log.writeln("uploading '"+ path +"' -> '" + blobName+"'");

我似乎无法找到合适的文档,并且正在谷歌搜索这些方法,因为我找到了它们。有人拿到 link 了吗?我想知道在使用 nodejs 上传文件时是否设置了 content-md5 字段。如果不是的话,nodejs 设置它的正确方法是什么(我知道如何计算它)。

请检查此处的代码:https://github.com/Azure/azure-storage-node/blob/ce2faa9ec63d9f3d9b27e90c3b5fd56330aa2cc2/lib/services/blob/blobservice.js#L2971。如您所见,有一个名为 options 的附加参数,您可以将其传递给该方法,您可以在其中手动指定 contentMD5。另请查看选项中的 storeBlobContentMD5。默认情况下,在块 blob 的情况下它设置为 true

@param {bool} [options.storeBlobContentMD5] Specifies whether the blob's ContentMD5 header should be set on uploads. The default value is true for block blobs.

你看到这里的代码了吗:https://github.com/Azure/azure-sdk-for-node/blob/master/lib/services/legacyStorage/lib/blob/blobservice.js (especially putBlockBlobFromFile)。除了您指定的参数之外,还有一个额外的 options 参数,您可以在其中定义其他参数,其中包括 content-md5。我自己没有使用过它,但查看选项似乎可以让 SDK 为您计算 MD5 - options.setBlobContentMD5: