Skip to content

feature/allow user upload pdf and pictures as notes#7

Open
xingyi1145 wants to merge 1 commit into
mainfrom
feature/allow-upload
Open

feature/allow user upload pdf and pictures as notes#7
xingyi1145 wants to merge 1 commit into
mainfrom
feature/allow-upload

Conversation

@xingyi1145
Copy link
Copy Markdown
Owner

This pull request adds support for file attachments to study notes, allowing users to upload images or PDFs when creating a note. The backend now handles file uploads, saves files to an uploads directory, and exposes them via a static file route. The frontend has been updated to allow users to attach files when creating notes and to display/download attachments in the note detail view.

Backend: File upload support and API changes

  • Added file upload handling to the create_note endpoint in notes.py, saving uploaded files to an uploads directory and storing their URLs in the database. ([src/backend/routes/notes.pyL18-R61](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-3d3bed194cbe8022155d326655a4c127b5aa445cd54b3a380094249e5c06660aL18-R61))
  • Updated the StudyNote model to include a new attachment_url field for storing the file URL. ([src/backend/models.pyR90](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-765ee555033cbc1c0a66d54c0e9b9df7c4ce513b94fb9925e91aa18ee452b5feR90))
  • Modified the API to serve files from the uploads directory using FastAPI's StaticFiles, ensuring the directory exists at startup. ([[1]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-7dc0ea0263421b070b14c289b52f9467996fb61796dbd1277b1c99ea1da14e4fR6-R8), [[2]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-7dc0ea0263421b070b14c289b52f9467996fb61796dbd1277b1c99ea1da14e4fR43-R48))

Frontend: File attachment UI and API integration

  • Updated the note creation form to allow users to select and upload a file (image or PDF) and send it as part of the note creation request. ([[1]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-a44c4fdee246de97a005c7ad7bc90209e0513d60144b62939a1a7ed63d1c225fR188), [[2]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-a44c4fdee246de97a005c7ad7bc90209e0513d60144b62939a1a7ed63d1c225fR203-R208), [[3]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-a44c4fdee246de97a005c7ad7bc90209e0513d60144b62939a1a7ed63d1c225fR247-R256))
  • Modified the API client to send note creation requests as multipart/form-data when a file is attached, and to handle the new attachment_url field. ([[1]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-eb8f64e76bf85ff0e9537eb54f79ae3c3a90d39267af822cbb236f69b07276bcR31-R42), [[2]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-eb8f64e76bf85ff0e9537eb54f79ae3c3a90d39267af822cbb236f69b07276bcR147-R157))

Frontend: Attachment display in note details

  • Enhanced the note detail page to display the attachment if present: images are shown inline, and other files (like PDFs) have a download/view link. ([src/frontend/src/pages/NoteDetailPage.tsxR130-R164](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-f8f0fb8ef6cc225bb55c005904c6f5c3c1e127e80c80bc8099b43637243fd709R130-R164))

Type and schema updates

  • Updated backend and frontend types/schemas to include the optional attachment_url and file fields for study notes. ([[1]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-2a677c3ac994f65d3efddfbb7d8dacd43c233e9124b206c42ebd76f132451d0aR91), [[2]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-7fede23556481c8377d7d1bb0e61cd114eff01799a6c568da0b935c42bcc5532R65), [[3]](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-7fede23556481c8377d7d1bb0e61cd114eff01799a6c568da0b935c42bcc5532R80))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant