-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from ReflectionsProjections/dev/aydan/add-batc…
…h-resumes Add batch download support for resumes
- Loading branch information
Showing
3 changed files
with
107 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from "zod"; | ||
|
||
const BatchResumeDownloadValidator = z.object({ | ||
userIds: z.string().array(), | ||
}); | ||
|
||
export default BatchResumeDownloadValidator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { GetObjectCommand, S3 } from "@aws-sdk/client-s3"; | ||
import Config from "../../config"; | ||
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; | ||
import { createPresignedPost } from "@aws-sdk/s3-presigned-post"; | ||
|
||
export async function postResumeUrl(userId: string, client: S3) { | ||
const { url, fields } = await createPresignedPost(client, { | ||
Bucket: Config.S3_BUCKET_NAME, | ||
Key: `${userId}.pdf`, | ||
Conditions: [ | ||
["content-length-range", 0, Config.MAX_RESUME_SIZE_BYTES], // 6 MB max | ||
], | ||
Fields: { | ||
success_action_status: "201", | ||
"Content-Type": "application/pdf", | ||
}, | ||
Expires: Config.RESUME_URL_EXPIRY_SECONDS, | ||
}); | ||
|
||
return { url, fields }; | ||
} | ||
|
||
export async function getResumeUrl(userId: string, client: S3) { | ||
const command = new GetObjectCommand({ | ||
Bucket: Config.S3_BUCKET_NAME, | ||
Key: `${userId}.pdf`, | ||
}); | ||
|
||
return getSignedUrl(client, command, { | ||
expiresIn: Config.RESUME_URL_EXPIRY_SECONDS, | ||
}); | ||
} |