'How do I serve an Image to client from Azure storage using Node API?
I use this function from azure/storage-blob package to retrive my file from Azure but how can I serve it to client using express API?
async function getData(container = 'newcontainer1646492958419', fileName = "splashscreen_image.png") {
const containerClient = blobServiceClient.getContainerClient(container);
const blockBlobClient = containerClient.getBlobClient(fileName);
const downloadBlockBlobResponse = await blockBlobClient.download(0);
const resp = await streamToString(downloadBlockBlobResponse.readableStreamBody)
return resp
}
async function streamToString(readableStream) {
return new Promise((resolve, reject) => {
const chunks = [];
readableStream.on("data", (data) => {
chunks.push(data.toString());
});
readableStream.on("end", () => {
resolve(chunks.join(""));
});
readableStream.on("error", reject);
});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
