
const fs = require("fs");
const imageUpload = picture => {
  var timestamp = Date.now();
  var uri = "producers/" + timestamp + ".jpg";
  var base64Data = picture.replace(
    /^data:image\/(png|jpeg|gif|jpg);base64,/,
    ""
  );
  fs.writeFile(
    "public/images/producers/" + timestamp + ".jpg",
    base64Data,
    "base64",
    async err => {
      console.log(err);
    }
  );
  var imgs = [];
  imgs['imagePaths'] = uri;
  imgs['timestamp'] = timestamp;
  return imgs;
};
module.exports = {
  imageUpload
};
