- Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
I am trying to upload some images to my cloud storage.
I am using form data to send the data down to the cloud function. The data arrives correctly, but the Busboy process never finishes processing it and the function timeouts after 60s.
Here is the implementation:
const firebase = require("firebase"); const Busboy = require("busboy"); require("firebase/storage"); const firebase_db = firebase_admin.database(); const firebase_storage = firebase.storage(); module.exports = (req, res) => { const busboy = new Busboy({headers: req.headers}); const fields = {}; const files = {}; busboy.on('field', (fieldname, val) => { fields[fieldname] = val; }); busboy.on('file', (fieldname, file, filename) => { files[fieldname] = file; }); busboy.on('finish', async () => { // ----> Function never fires try { let project_id = await firebase_db.ref("/project_config/project_id").once("value") project_id = project_id.val() if (!project_id) return res.send({ message: "Project ID not found" }) const new_image_storage_ref = firebase_storage.ref().child(`${project_id}/${fields.route}`) const snapshot = await new_image_storage_ref.put(files.image) const download_url = await snapshot.ref.getDownloadURL() res.send(download_url) } catch (error) { console.log("----- Error during saving content data ", error) res.send({ message: "Error during saving your image, please re-load page and try again or contact support." }) } }); } Do you have any idea what might be causing it?
Metadata
Metadata
Assignees
Labels
No labels