Reputation: 611
I want to create a HTTP trigger Firebase Function which basically gets the image url from request, downloads the image, stores the image in storage and then returns the new image url from storage. The code looks like this so far:
const functions = require('firebase-functions');
exports.mirror = functions.https.onRequest((req, res) => {
var url = req.query.url
//TODO: Download image from `url`.
//TODO: Store downloaded image in Firebase Storage.
//TODO: Return new image path in Firebase Store.
res.status(200).send(url)
});
How should I go on about solving this?
Upvotes: 1
Views: 1786
Reputation: 83048
This could be done by using a mix of the techniques and libraries shown in these examples or documentation items. Just study these examples and documentation and you should be able to assembly all the pieces together.
The following Cloud Functions samples for image saving and retrieving
https://cloud.google.com/nodejs/docs/reference/storage/1.6.x/
Upvotes: 3