Skip to content

Commit

Permalink
feat: update upload route
Browse files Browse the repository at this point in the history
  • Loading branch information
Labham-Jain committed Oct 9, 2023
1 parent 9e01300 commit 1ce8019
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Binary file modified dump.rdb
Binary file not shown.
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cors from 'cors'
import { deleteCustomer } from "./routes/admin/delete-customer";
import { listDeletedCustomers } from "./routes/admin/list-deleted";
import { restoreCustomer } from "./routes/admin/restore-customer";
import { uploadFile } from "./routes/store/uploads";
import { uploadFile } from "./routes/global/uploads";
import { S3Client } from "@aws-sdk/client-s3";

export default (rootDirectory: string): Router | Router[] => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ export const uploadFile = (router: Router, { s3Client }: { s3Client: S3Client })
return res.status(403).send()
}
}
const ext = req.query.ext as string
if (!ext) return res.status(422).send('Missing file extension!');


const id = req.user.customer_id || req.user.userId;

const key = `${id}/${ulid()}`
const key = `${id}_${ulid()}.${ext}`
const command = new PutObjectCommand({ Bucket: process.env.AWS_BUCKET, Key: key });

const url = await getSignedUrl(s3Client, command, { expiresIn: 300 }); // 5 minutes
Expand Down

0 comments on commit 1ce8019

Please sign in to comment.