feature/allow user upload pdf and pictures as notes#7
Open
xingyi1145 wants to merge 1 commit into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
uploadsdirectory, 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
create_noteendpoint innotes.py, saving uploaded files to anuploadsdirectory 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))StudyNotemodel to include a newattachment_urlfield for storing the file URL. ([src/backend/models.pyR90](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-765ee555033cbc1c0a66d54c0e9b9df7c4ce513b94fb9925e91aa18ee452b5feR90))uploadsdirectory using FastAPI'sStaticFiles, 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
[[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))multipart/form-datawhen a file is attached, and to handle the newattachment_urlfield. ([[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
[src/frontend/src/pages/NoteDetailPage.tsxR130-R164](https://github.com/xingyi1145/SE-StudyCenter/pull/7/files#diff-f8f0fb8ef6cc225bb55c005904c6f5c3c1e127e80c80bc8099b43637243fd709R130-R164))Type and schema updates
attachment_urlandfilefields 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))