I'm trying to download a image/file from an url which I receive from typeform but this is a direct download and not a picture you can actually view with the url.
I've succesfully made a buffer from it with bent:
const bent = require('bent');
const getBuffer = bent('buffer');
async function getBase64FromFileAsync(fileUrl) {
let bentbuffer = await getBuffer(fileUrl); // returns hex string
return bentbuffer.toString('base64');
// ^ Base64 string
}
Where I was unsuccesful with js:
let fsbuffer = fs.readFileSync(fileUrl);
// ^ undefined
But with this I can't actually seem to do anything so that I can save the image to the firebase store.
I tried using the createReadSteam & createWriteStream with the actually url, base64 or even hex string
const remoteFile = bucket.file('image.png');
fs.createReadStream(fileUrl)
.pipe(remoteFile.createWriteStream({
I tried the bucket.upload method also with the url, base64 and hex but upload requires an actual local file (which is not possible as it's a google cloud function (read-permissions only))
getBase64FromFileAsync(fileUrl)
.then(base64 => {
bucket.upload(base64, options, function (err, file) {
Is it possible to upload a file without downloading a local copy to "move" to the firebase storage or am I creating the file in a bad way?