【问题标题】:Can't download blobs inside a folder using Node.js SDK无法使用 Node.js SDK 下载文件夹内的 blob
【发布时间】:2019-04-04 02:47:41
【问题描述】:

我正在尝试在 azure 中的 blob 容器中下载一些 blob。

当文件在根容器上时我成功了,但在文件夹中时没有。

const folder = 'AZURE_FOLDER';

const filesToDownload =  [ 'icon.ico', 'images/cover.jpg', 'images/htmlstructure.png' ]

filesToDownload.forEach(blob => {
      service.download(containerName, blob, `${folder}/${blob}`)
});

运行此代码,下载的文件是“icon.ico”,但其他所有文件都收到此错误:

error : { Error: ENOENT: no such file or directory, open 'AZURE_FOLDER/images/cover.jpg'

error : { Error: ENOENT: no such file or directory, open 'AZURE_FOLDER/images/htmlstructure.png'

我的 listBlobs 回复:

BlobResult {
  name: 'images/cover.jpg',
  creationTime: 'Wed, 03 Apr 2019 17:14:03 GMT',
  lastModified: 'Wed, 03 Apr 2019 17:14:03 GMT',
  etag: '0x8D6B857C5B2B355',
  contentLength: '299040',
  contentSettings: 
   { contentType: 'image/jpeg',
     contentEncoding: '',
     contentLanguage: '',
     contentMD5: 'JqJRnPltEsAhar+YfKgEtQ==',
     cacheControl: '',
     contentDisposition: '' },
  blobType: 'BlockBlob',
  accessTier: 'Hot',
  accessTierInferred: true,
  lease: { status: 'unlocked', state: 'available' },
  serverEncrypted: 'true' }
BlobResult {
  name: 'images/htmlstructure.png',
  creationTime: 'Wed, 03 Apr 2019 17:14:02 GMT',
  lastModified: 'Wed, 03 Apr 2019 17:14:02 GMT',
  etag: '0x8D6B857C4ECA732',
  contentLength: '65835',
  contentSettings: 
   { contentType: 'image/png',
     contentEncoding: '',
     contentLanguage: '',
     contentMD5: 'uHsFKqK9csssX0XYt86dlA==',
     cacheControl: '',
     contentDisposition: '' },
  blobType: 'BlockBlob',
  accessTier: 'Hot',
  accessTierInferred: true,
  lease: { status: 'unlocked', state: 'available' },
  serverEncrypted: 'true' }
BlobResult {
  name: 'user.ico',
  creationTime: 'Wed, 03 Apr 2019 16:58:24 GMT',
  lastModified: 'Wed, 03 Apr 2019 16:58:33 GMT',
  etag: '0x8D6B8559B5CC9C8',
  contentLength: '179677',
  contentSettings: 
   { contentType: 'image/x-icon',
     contentEncoding: '',
     contentLanguage: '',
     contentMD5: 'sHZ3nvd9fyX09EkqQvDvLQ==',
     cacheControl: '',
     contentDisposition: '' },
  blobType: 'BlockBlob',
  accessTier: 'Hot',
  accessTierInferred: true,
  lease: { status: 'unlocked', state: 'available' },
  serverEncrypted: 'true' }

【问题讨论】:

  • 也许你应该为 nodejs 使用 azure sdk
  • 我已经在用了,谢谢

标签: javascript node.js azure azure-blob-storage


【解决方案1】:

AZURE_FOLDER/images 目录是否存在?如果没有,您需要事先使用fs 模块创建它。

【讨论】:

  • 我创建了 images 文件夹,值得!
  • 很高兴它成功了!如果对您有帮助,请不要忘记接受答案;)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-06-20
  • 2018-04-13
  • 2018-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多