-
Notifications
You must be signed in to change notification settings - Fork 61
add resume upload button #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
6dbd6e0
add nonfunctional resume upload field
anna-sage 2395cbd
validate resumeUpload input is FileList type
anna-sage 86bca3c
validate number of files in file list
anna-sage 28c2152
validate resume file is pdf
anna-sage 3fbd84c
refactor zod refinements to single superrefine
anna-sage 6e6b318
validate file size doesn't exceed 5MB
anna-sage eb7fdfd
validate type of FileList object
anna-sage 3232d44
remove testing console log
anna-sage 2704a89
install minio client library
anna-sage 3475a13
install aws sdk dependencies
anna-sage 9271c56
create empty upload api route file
anna-sage 52e22e5
instantiate minio client (not working)
anna-sage 9c6dde9
add skeleton code for new resume upload route
anna-sage 79d6963
add resume upload router to tRPC routers
anna-sage f74086b
removed unused file
anna-sage d5b900b
add minio version to blade dependencies
anna-sage 2ea642d
write initial resume upload frontend logic
anna-sage 63fc81a
add initial resume upload router logic
anna-sage 02d261b
update .env.example with MinIO access variables
anna-sage e9db6a2
update env module with MinIO access variables
anna-sage 199cbed
add tRPC route for resumes (progress)
anna-sage 2a0da03
auto-fix issue with lock file
anna-sage 407f786
resolve type error
anna-sage 3c17dff
convert file to base64 string for client to server transmission
anna-sage 8b35359
add typechecking for base 64 data
anna-sage 736166e
fix lint issues
anna-sage bda4b20
fix typecheck issue
anna-sage 16f900c
run prettier on everything
anna-sage 5199388
reorder dependencies
anna-sage 838b729
return path to resume instead of resume url (to generate presigned url)
anna-sage b483307
configure ssl
anna-sage f1b0331
overwrite old resumes before uploading
anna-sage cc40a49
run prettier again
anna-sage 548e907
resolve comments
Lewin-B 09adefa
Add tanstack table to blade
Lewin-B da3be3c
Add grad date to the member form
Lewin-B 7df93bb
Add grad date to member profile
Lewin-B 0f6099c
styling changes
Lewin-B File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -36,8 +36,5 @@ | |
| "overrides": { | ||
| "@types/node": "^22.10.1" | ||
| } | ||
| }, | ||
| "dependencies": { | ||
| "@tanstack/react-table": "^8.20.6" | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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,74 @@ | ||
| import type { ItemBucketMetadata } from "minio"; | ||
| import { TRPCError } from "@trpc/server"; | ||
| import { Client } from "minio"; | ||
| import { z } from "zod"; | ||
|
|
||
| import { KNIGHTHACKS_S3_BUCKET_REGION } from "@forge/consts/knight-hacks"; | ||
|
|
||
| import { env } from "../env"; | ||
| import { protectedProcedure } from "../trpc"; | ||
|
|
||
| const s3Client = new Client({ | ||
| endPoint: env.MINIO_ENDPOINT, | ||
| useSSL: true, | ||
| accessKey: env.MINIO_ACCESS_KEY, | ||
| secretKey: env.MINIO_SECRET_KEY, | ||
| }); | ||
|
|
||
| export const resumeUploadRouter = { | ||
| uploadResume: protectedProcedure | ||
| .input( | ||
| z.object({ | ||
| fileName: z.string(), | ||
| fileContent: z.string(), // Base-64 encoded | ||
| }), | ||
| ) | ||
| .mutation(async ({ input, ctx }) => { | ||
| const { fileName, fileContent } = input; | ||
|
|
||
| // Decode Base64 to Buffer | ||
| const base64Data = fileContent.split(",")[1]; // Remove metadata prefix | ||
| if (base64Data) { | ||
| const fileBuffer = Buffer.from(base64Data, "base64"); | ||
|
|
||
| const bucketName = "member-resumes"; | ||
| const userDirectory = `${ctx.session.user.id}/`; | ||
| const filePath = `${userDirectory}${fileName}`; | ||
|
|
||
| // Ensure bucket exists | ||
| const bucketExists = await s3Client.bucketExists(bucketName); | ||
| if (!bucketExists) { | ||
| await s3Client.makeBucket(bucketName, KNIGHTHACKS_S3_BUCKET_REGION); | ||
| } | ||
|
|
||
| // Overwrite any existing resume associated with the user | ||
| const existingResumes = []; | ||
| const objectStream = s3Client.listObjects( | ||
| bucketName, | ||
| userDirectory, | ||
| true, | ||
| ); | ||
| for await (const obj of objectStream as AsyncIterable<ItemBucketMetadata>) { | ||
| existingResumes.push(obj.name); | ||
| } | ||
|
|
||
| if (existingResumes.length > 0) { | ||
| await Promise.all( | ||
| existingResumes.map(async (objectName: string) => { | ||
| await s3Client.removeObject(bucketName, objectName); | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| await s3Client.putObject(bucketName, filePath, fileBuffer); | ||
|
|
||
| // Path to the resume within the bucket | ||
| return filePath; | ||
| } else { | ||
| throw new TRPCError({ | ||
| code: "BAD_REQUEST", | ||
| message: "Base64 data is missing or invalid", | ||
| }); | ||
| } | ||
| }), | ||
| }; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and other zod issues/errors/not user-facing strings can have more consistent punctuation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give an example?