New question
When I overwrite a blob and then update the browser is still caching the main image and not the new one. I have read that there is a cache-control property but I can not implement it. I need to clean the blob cache that has just been uploaded
Old question
I am trying to overwrite an existing blob using connect-busboy middleware and the following method, but the file is not overwritten and I do not understand why.
createBlockBlobFromStream(container, blob, (Stream), streamLength,
options, callback) → {SpeedSummary}Uploads a block blob from a stream. If the blob already exists on the service, it will be overwritten.
app.post('/upload', function(req, res, params) {
var name;
req.busboy.on('field', function (fieldname, val) {
name = val+'.jpg';
});
req.busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
file.on('data', function (data) {
console.log(name);
console.log(data);
var bufferStream = new stream.PassThrough();
bufferStream.end(data);
var blobSvc = azure.createBlobService(accountName, accountKey);
blobSvc.createBlockBlobFromStream('images', name, bufferStream, data.length, function (error, result, response){
if (!error) {
res.send(200,'upload succeeded')
} else {
res.send(500,JSON.stringify(error))
}
})
});
});
});
Per Azure Storage SDK for Node API Reference,
So you are doing right to overwrite the existing blob file with Azure Storage SDK for Node.
Edit:
Seems you have encountered upload issue. I would recommend you to try using createWriteStreamToBlockBlob instead of
createBlockBlobFromStream
to upload blob to Azure storage. The following example works by using connect-busboy middleware. create /public folders. Use the folder structure:\index.js
\public\index.html
INDEX.JS
INDEX.HTML