Azure-sdk-for-js: Is there a way to use uploadBrowserData() method in @azure/storageblob to upload directly to a folder inside a blob

Created on 15 Mar 2021  路  6Comments  路  Source: Azure/azure-sdk-for-js

  • Package Name: @azure/storage-blob
  • Package Version: 12.4.1
  • Operating system: Windows 10
  • [ ] nodejs

    • version: v14.15.2

  • [ ] browser

    • name/version: Chrome

  • [ ] typescript

    • version: 3.9.5

  • Is the bug related to documentation in

Describe the bug
This is a question. Is there a way to use uploadBrowserData() method in @azure/storageblob to upload directly to a folder inside a blob?

To Reproduce
Steps to reproduce the behavior:

  1. Follow sample from upload a file to Azure Blob

Expected behavior
either folder can be added in a blob client URL or options can be set in BlockBlobParallelUploadOptions class in the uploadBrowserData() method.

Screenshots

Additional context

Client Storage customer-reported needs-team-attention question

Most helpful comment

Yes, I am trying to upload a blob directly to a path already created inside the container using the .net method.

@kktam you should be able to do that by naming your blob accordingly.

  const blobClient = containerClient.getBlockBlobClient(`folder1/folder2/blob-${id}.txt`);
  const res = await blobClient.uploadData(buffer);
  console.log(res);

Is there an issue you are hitting?

All 6 comments

Who do you mean by a folder inside a blob?

@kktam are you using some path separator for your hierarchy? I suppose you can give your blob a name like path/to/my/blob to achieve the goal?

Who do you mean by a folder inside a blob?

Yes, I am trying to upload a blob directly to a path already created inside the container using the .net method.

Yes, I am trying to upload a blob directly to a path already created inside the container using the .net method.

@kktam you should be able to do that by naming your blob accordingly.

  const blobClient = containerClient.getBlockBlobClient(`folder1/folder2/blob-${id}.txt`);
  const res = await blobClient.uploadData(buffer);
  console.log(res);

Is there an issue you are hitting?

Yes, I am trying to upload a blob directly to a path already created inside the container using the .net method.

@kktam you should be able to do that by naming your blob accordingly.

  const blobClient = containerClient.getBlockBlobClient(`folder1/folder2/blob-${id}.txt`);
  const res = await blobClient.uploadData(buffer);
  console.log(res);

Is there an issue you are hitting?

@jeremymeng the code snippet is correct. I am now able to load a file directly inside a folder now. Thanks.

@kktam Glad to know that it is working for you! I am closing this. Please open new issues if you have any other feedback.

Was this page helpful?
0 / 5 - 0 ratings