繁体   English   中英

在Node.js项目中显示Azure子文件夹

[英]Display Azure Subfolders in Node.js project

我正在尝试使用Azure和数据存储使用Node和Express进行文件共享。

我正在努力显示容器的子文件夹。

我的代码如下所示:

  1. 我创建这样的子文件夹,以隐藏'$$$。$$$'文件:

     app.post('/folderhandler', function (req, res) { var containerName = req.query.id; var folderName = req.body.folderName; var folder = folderName + '/$$$.$$$'; blobSvc.createBlockBlobFromText( containerName, folder, 'Hello, World!', function (error, result, response) { if (error) { console.log("Couldn't upload string"); console.error(error); } else { console.log('String uploaded successfully'); } }); res.redirect('/container/' + containerName); }); 
  2. 然后,我尝试使用新的“子文件夹”作为displayBlobs函数中的“容器”变量。 但这不起作用:

      app.get('/container/:containername/:subcontainer', function (req, res) { var containerName = req.params.containername; var subContainer = req.params.subcontainer; blobSvc.listContainersSegmented(null, function (err, containers) { blobSvc.listBlobsSegmented(subContainer, null, function (error, blobs) { res.render('manager.ejs', { error: error, title: 'Manager ' + containerName, pageID: 'containers', containername: subContainer, listContainers: containers.entries, listBlobs: blobs.entries, breadcrumbs: [{ href: '/manager', text: 'Manager' }, { href: '/container/' + containerName, text: containerName }, { text: subContainer, active: true }] }); }); }); }); 

我想我已经尝试了所有方法,因此即时消息公开:)

  • 提前致谢!

也许您在函数listBlobsSegmented(container, currentToken [, options], callback)犯了一个错误,第一个参数应该是容器名称,而不是子文件夹名称。

如果要在子文件夹中显示blob项,请改用函数listBlobsSegmentedWithPrefix(container, prefix, currentToken [, options], callback) ,然后可以将子文件夹名称作为第二个参数prefix传递。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM