-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add patch endpoint for attachment metadata #27 #95
Add patch endpoint for attachment metadata #27 #95
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #95 +/- ##
===========================================
+ Coverage 99.57% 99.59% +0.02%
===========================================
Files 19 19
Lines 468 492 +24
===========================================
+ Hits 466 490 +24
Misses 2 2 ☔ View full report in Codecov by Sentry. |
…orage-api into add-patch-endpoint-for-attachment-metadata-#27
- when merging in develop, ome reason half the routers file was just deleted
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.
All looks good, I actually do have 1 minor suggestion, which I realised after approving
This PR addressed an issue where the file extension could be edited to not match the content type of an image, making it unopenable. I think the same problem exists for attachments, and could be addressed with the same implementation. The update portion of it could be covered in this PR, or be made a separate issue? |
yeah the same problem does exist for attachments, I'll look into it. |
My last commit checks for file extension and content type mismatch when an attachment is being edited, but not when its being created. I don't think I can follow the same implementation as images (as seen at https://github.com/ral-facilities/object-storage-api/pull/82/files#diff-89e412be5e05de57abb22dd8b7385de050592624f92bef53c8447c019f2fa3faR59), as attachments doesn't have an |
Yeah I would personally do it as a separate PR linking #96. Yes the content type is irrelevant in this case as it is always treated as binary data. My personal thought would be that the same logic preventing changing of the file extension on edit should still be fine - you can compare the old and new extension. But for upload there is nothing to prevent as we don't know the content type so its purely up to the front end instead. Good spot with the library, that would also allow invalid images to be detected even if the content type/extension was manually manipulated. The only issue with it is it doesn't look like its had an update for 3 years so I would prefer to avoid using it if possible. |
ok thanks. So can this PR stay as it is, and the check when uploading attachments can be done in a different issue/pr? Or would you like the check when patching an attachment in a separate pr as well? |
Ignore the upload attachments on the backend (the front end issue should prevent it instead), only add the check for editing attachments, I think you have already done it in this PR? In which case that is fine, it can be left as part of this PR and just link the issue in the description by adding another resolves/closes on it. |
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.
Works well, and testing and implementation looks good.
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.
Looks good, worked well for me.
Description
Implements a PATCH endpoint /attachment/<attachment_id> that:
Also prevents a file extension and content type mismatch when editing an attachment.
Testing instructions
Add a set up instructions describing how the reviewer should test the code
Agile board tracking
Resolves #27
Resolves #96