Images with 0 bytes in azure storage container blob RRS feed

  • Question

  • In my web application, photos are sent to an azure container. The problem is that randomly many images fall into the container with a size of 0 bytes, therefore unusable. I have reviewed the azure linux server and I have noticed that the web application always sends the photos well. Because I keep them temporarily and keep them with the correct sizes. The problem is when I send them, which sends some with 0 bytes.

    The system sends the photos correctly when I test it locally or when I try it on other platforms like heroku. I do not understand why only in Azure causes this problem.

    This is my code, but I repeat, locally and in other platforms it works well even using the azure container. I think it's configuration of the web app within azure. But I do not know.

     let almacenamiento = multer.diskStorage({
        destination: function (req, file, cb) {
          cb(null, 'uploads')
        filename: function (req, file, cb) {
          cb(null,Date.now() + '-' + file.originalname);
      let upload = multer({ storage: almacenamiento,
                            fileFilter: function (req, file, cb) {
                              let ext = path.extname(file.originalname);
                              const regex =  /(\.JPEG|\.jpeg|\.png|\.PNG|\.jpg|\.JPG)+/g;
                            if (!ext.match(regex)) {
                              return cb(new Error('El archivo debe ser una imagen!'))
                            cb(null, true)
                          limits: { fileSize: 5*1024*1024 }
    function create (req, res) {
        blobService.createBlockBlobFromLocalFile(container, req.file.filename, req.file.path, function(error, result, response) {
                reception_file_url: result.name,
                reception_file_comment: req.body.comentario,
                file_type_id: req.body.idreferencia,
                reception_id: req.body.recepcion
              .save(null,{method: 'insert'})
              .then(function(archivo) {
                  fs.unlink(path.resolve('./', 'uploads',archivo.attributes.reception_file_url), (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /uploads/'+archivo.attributes.reception_file_url);
                    res.json({error: false, data: archivo.toJSON()});
                 res.status(500).json({error: true, data: {message: error.message}});
    router.post('/',upload.single('imagen'), create);

    Monday, April 9, 2018 6:28 PM

All replies