'Read xlsx file and json file with url signed on azure blob storage using nodejs

I intend to read the contents of an xslx and json files on an azure blob storage with the urls signed with a limited life-to-live.

I did this as :

        const file = readFileSync(urlSignedBlobStorageForJSON);
        console.log(file);
        //console.log(JSON.parse(file.toString()));

I think it can be accessed for the life-to-live of the file without going through the azure blob storage credential as :

blobClient.createBlockBlobFromStream(containerName,filename,streamifier.createReadStream(new Buffer(filedata)), filedata.length,options,(err,result)....

I have errors (Error: ENOENT: no such file or directory) using readFileSync(urlSignedBlobStorageForJSON).

How to read the content of this json file?



Solution 1:[1]

• Thank you @Motra for your question about reading ‘.xlsx’ and ‘.json’ files from the blob storage with the urls signed with a limited life-to-live. It will surely be a valuable addition to the SO community. For the same purpose as stated, posting your comment as an answer as it will be easier for other people with same issue to find it.

Rather than using ‘readFileSync(urlSignedBlobStorageForJSON)’ as a variable to indicate the file to be read from the blob storage, use ‘axios.get(urlBlobStorageData)).data’ to read the content from the blob storage account.

This would help you in reading the contents from ‘.xlsx’ and ‘.json’ files with URLs signed for a limited life-to-live.

• Also, please refer to the below SO community thread for more detailed information on the appropriate use of above said cmdlet in nodejs: -

node.js axios download file stream and writeFile

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KartikBhiwapurkar-MT