Skip to content

Commit

Permalink
Merge branch 'main' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptisteLecat committed Jul 24, 2024
2 parents de63f37 + 406f86c commit 7ef0cab
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ export const onGenerationCreated = functions.runWith({ timeoutSeconds: 160 }).re
throw new Error("Unable to generate image");
}

//Upload iri image to firebase storage
const bucket = admin.storage().bucket();
const file = bucket.file(`generations/${generationId}.png`);
await file.save(Buffer.from(generatedImage.uri, 'base64'), {
contentType: 'image/png',
public: true,
metadata: {
cacheControl: 'public, max-age=31536000',
},
});

//Get the public url of the image
const [url] = await file.getSignedUrl({
action: 'read',
expires: '03-09-2491',
});

generatedImage.uri = url;

//Save image to firestore
generation.generatedImage = generatedImage;
generation.progress = 100;
Expand Down

0 comments on commit 7ef0cab

Please sign in to comment.