Skip to content

Instantly share code, notes, and snippets.

@EarthenLynx
Last active September 16, 2020 19:48
Show Gist options
  • Save EarthenLynx/627bda0a16a3d6485f3bb32111d75009 to your computer and use it in GitHub Desktop.
Save EarthenLynx/627bda0a16a3d6485f3bb32111d75009 to your computer and use it in GitHub Desktop.
const saveImgTemp = function (req, res, next) {
const writeStream = fs.createWriteStream(
path.join(__dirname, "../store/test.png")
);
req.pipe(writeStream);
// After all the data is saved, respond with a simple html form so they can post more data
req.on('end', function () {
res.send({msg: "Works"})
});
// This is here incase any errors occur
writeStream.on('error', function (err) {
console.log(err);
});
};
handleSendImage() {
const server = this.host;
fetch(this.image)
.then((img) => img.blob())
.then((blob) => {
fetch(server, {
method: 'POST',
body: blob,
responseType: 'stream',
headers: {
'content-type': blob.type,
},
});
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment