0
I have this problem and I have no idea how to solve, I want to save images in Azure Storage
const blobSvc = azure.createBlobService(config.containerConnectionString);
let filename = guid.raw().toString() + '.jpg';
let rawdata = req.body.image;
let matches = rawdata.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/);
let type = matches[1];
let buffer = new Buffer(matches[2], 'base64');
await blobSvc.createBlockBlobFromText('images', filename, buffer, {
contentType: type
}, function (error, result, response) {
if (error) {
filename = 'default-product.png'
}
});
The error is pointed here
Let type = Matches[1];
but I can’t understand to solve, and the error message:
Typeerror: Cannot read Property '1' of null
it doesn’t help much, someone can help?
That mistake is probably because the
match
is null. IE, found nothing with the regex used.– Sam