如何使用 azure-storage-node 按修改日期查询 Azure Blob

How to query Azure Blobs by modification date using azure-storage-node

我正在使用 Azure Blob 存储节点库: https://github.com/Azure/azure-storage-node

我参考了这个文档: https://github.com/Azure/azure-content/blob/master/articles/storage-nodejs-how-to-use-blob-storage.md

我可以很好地执行大多数 blob 操作,但我想列出一周内未修改的 blob。该文档非常简单,但似乎有一个我可以使用的访问条件,我只是不确定语法。这是我最好的猜测:

var weekOld = new Date();
weekOld.setDate(weekOld.getDate() - 7);

var options = {accessConditions:{}};
options['accessConditions'][azure.BlobUtilities.AccessConditions.DATE_UNMODIFIED_SINCE] = weekOld;

blobSvc.listBlobsSegmentedWithPrefix('mycontainer', 'myprefix', null /*token*/, options, function(error, result, response){
    if(!error){
        result.entries.forEach(function(val, index, array){
            console.log(val.name);
            console.log(val.properties);
        });
    }
    console.log(response);
});

这会拉入所有具有正确前缀的 blob,但会忽略修改日期。我正在猜测通过我的查询传递 accessConditions 的语法,所以这不起作用也就不足为奇了。非常感谢任何帮助。

无法在列出 blob 时使用访问条件对 blob 进行服务器端过滤,因为 List Blobs REST API operation doesn't support conditional headers. For the operations supporting conditional headers, please see Specifying Conditional Headers for Blob Service Operations(标题为:Operations Supporting Conditional Headers 的部分)。

最好的选择是列出 blob,然后在客户端进行过滤。