I have an image URLs. But these URL can be removed soon. So I should store them into my server.
I choose Firebase Storage as the image server. And I have a Node.js on AppEngine.
Actually, I am a newbie of Node.js, Web Dev. (I am an Android developer.)
I found the image download code.
var fs = require('fs'),
request = require('request');
var download = function(uri, filename, callback){
request.head(uri, function(err, res, body){
console.log('content-type:', res.headers['content-type']);
console.log('content-length:', res.headers['content-length']);
request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
});
};
download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function(){
console.log('done');
});
After that, I can upload this image into the Firebase Storage.
But in this case I think it stores the image data into AppEngine too, right? I don't want to it. I want to store it only into the Firebase Storage.
I can remove the file on AppEngine. But is there any more clear way?
I think the best case (what I want) is
download the image from URL into the Byte Array on memory
ANd upload it to Firebase Storage.
How can I do this?