Skip to content

Commit

Permalink
Merge pull request #42 from curiosta/feat/add-upload-functionality
Browse files Browse the repository at this point in the history
Feat/add upload functionality
  • Loading branch information
Labham-Jain authored Oct 9, 2023
2 parents d77a11f + bd58520 commit faf78c3
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 faf78c3

Please sign in to comment.