Skip to content

Commit

Permalink
Update index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
daoauth committed Jul 16, 2024
1 parent 4d68ae2 commit fc7056a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import { DocData } from './types';
admin.initializeApp({
credential: admin.credential.cert(serviceAccount as admin.ServiceAccount),
});
const storage = new Storage();

/**
* Uploads a file to Firebase Cloud Storage.
* Expects the request body to contain 'filename', 'contentType', and 'file' (base64 encoded).
*/
export const upload = onRequest(async (req, res) => {
const storage = admin.storage();
const bucket = storage.bucket('slsa-on-blockchain.appspot.com');
const file = bucket.file(req.body.filename);
const stream = file.createWriteStream({
Expand All @@ -50,6 +50,7 @@ export const upload = onRequest(async (req, res) => {
* Returns the file contents as a base64 encoded string.
*/
export const download = onRequest(async (req, res) => {
const storage = admin.storage();
const bucket = storage.bucket('slsa-on-blockchain.appspot.com');
const file = bucket.file(req.body.filename);

Expand Down

0 comments on commit fc7056a

Please sign in to comment.