I have this problem and I have no idea how to solve it, 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 out here
let type = matches [1];
But I can not figure out how to solve it, and the error message:
TypeError: Can not read property '1' of null
It does not help much, can anyone help?