
const fs = require("fs");
const imageUpload = picture => {
  var timestamp = Date.now();
  var filePath = "public/images/customer/userWithId/" + timestamp + ".jpg"

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