-
Notifications
You must be signed in to change notification settings - Fork 189
[Core] Create File Uploader class to standardize and validate file uploads in LORIS #4181
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
Conversation
Some Design Choices
|
|
This needs documentation but is ready for testing. |
PapillonMcGill
left a comment
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.
just a few typo in the text
This comment has been minimized.
This comment has been minimized.
|
Thanks for the review @xlecours. I addressed some of your points above. I'll also make the rest of the changes you mentioned. |
driusan
left a comment
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.
One comment change that was confusing, and one that was an obvious typo..
Co-Authored-By: Dave MacFarlane <[email protected]>
Co-Authored-By: Dave MacFarlane <[email protected]>
|
@driusan I applied your suggestions |
|
@driusan Thoughts on merging this? |
|
@zaliqarosli Do you mind approving again? Dave asked that i make changes to the documentation but the code is the same as when you last approved |
xlecours
left a comment
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.
I have added @cmadjar comments that were made on a PR in which I use those classes.
| $message = 'Failed to write file to disk'; | ||
| break; | ||
| case UPLOAD_ERR_EXTENSION: | ||
| $message = 'File upload stopped by extension'; |
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.
@cmadjar says:
not sure I understand this error. Is it because the extension of the uploaded file is not zip, tar.gz, tar or tgz? If so, maybe rephrase to: "Wrong extension of the file to upload"? Or something like that?
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.
Same here.
Also I think we should just go by MIME type. We can check extensions on the front-end if we want to but they don't really matter as long as the actual content is 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.
Mime type or not, we need to handle this error code.
I think I copy&pasted that https://www.php.net/manual/en/features.file-upload.errors.php#89374
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.
Also, reading the description, this is not related to the file extension but rather to a php extension in php.ini
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.
OK so then there are no changes to make?
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.
If @cmadjar asked, then we should probably clarify. It could be File upload stopped by a php extension
Documentation typos Co-Authored-By: Xavier Lecours <[email protected]>
Co-Authored-By: Xavier Lecours <[email protected]>
| * | ||
| * @param \SplFileInfo $uploadDirectory The target upload directory | ||
| */ | ||
| public function __construct(\SplFileInfo $uploadDirectory) |
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.
Just a comment/suggestion
The constructor signature should/could be
public function __construct(
\SplFileInfo $uploadDirectory,
array $permittedMIMETypes = [],
int $permissions = 0644,
bool $overwrite = false
)
That way the default values for the class variables could be removed but you would need to set them in the constructor code block. I think it facilitates the instantiation for non-default values.
Feel free to change it or not (It's your PR.)
|
🎉🎉🎉 |
Brief summary of changes
This PR picks up on #3514 and introduces an attempt at creating a generic File Upload (Validator) class for use in LORIS file uploads. See attached issue for more details.
The newly Reactified
instrument_manageris used as an example to demonstrate how this class should be used.Related
#4182.
To test this change...