yigitserin
yigitserin

Reputation: 611

How to download image and store it in database with Firebase functions?

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

Answers (1)

Renaud Tarnec
Renaud Tarnec

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.

Upvotes: 3

Related Questions