Last active
September 16, 2020 19:48
-
-
Save EarthenLynx/627bda0a16a3d6485f3bb32111d75009 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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