BlobNotFound when using syncCopyFromURL

Utkarsh 1 Reputation point
2020-10-19T09:48:56.61+00:00

Hello,
I am using @azure/storage-blob npm and am trying to figure out a way to add an image directly from url to blob. What I came up with was :

const blobService4 = new BlockBlobClient(
      process.env.AZURE_CONNECTION_STRING,
      containerName,
      blobName,
    );

let a = await blockBlobClient.syncCopyFromURL(url)
return a

What this did for me was save it inside the container, but the url was not public or what, I am not quite sure , but i wasn't able to access the image. What I want is to store the image to the container and display it as the products image. What I get is BlobNotFound Error. Can any one tell me what I am doing wrong ?

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,570 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. deherman-MSFT 34,841 Reputation points Microsoft Employee
    2020-10-19T15:49:11.64+00:00

    @Utkarsh
    If you wish to make blobs public you need to change the access level on the container. Once this is set any new blob uploaded to the containers should be public.

    Please update the setting and let me know if resolves your issue.

    ------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


  2. deherman-MSFT 34,841 Reputation points Microsoft Employee
    2020-10-23T17:01:48.9+00:00

    @Utkarsh The difference is that the blob that used syncCopyFromURL has a content type of application/octet-stream. There was a similar thread here. Try to see if you can modify the content type to image/jpeg using blobHTTPHeaders.

    Hope this helps! Let me know if it does not resolve your issue.

    -------------------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.