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
Fixes for Media Library upload #5971
Conversation
Keep original file name including extension
File name was not set for all generated media: thumbnail and resized pictures.
Codecov Report
@@ Coverage Diff @@
## master #5971 +/- ##
==========================================
+ Coverage 19.86% 19.98% +0.12%
==========================================
Files 857 858 +1
Lines 12078 12094 +16
Branches 1963 1965 +2
==========================================
+ Hits 2399 2417 +18
+ Misses 8094 8092 -2
Partials 1585 1585
Continue to review full report at Codecov.
|
@@ -42,6 +42,7 @@ const generateThumbnail = async file => { | |||
const { width, height, size } = await getMetadatas(newBuff); | |||
|
|||
return { | |||
name: `thumbnail_${file.name}`, |
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.
the filename might be really strange here as it can be set by the user. What was the need for it here ?
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.
The name attribute should be set for all media files because it goes to the same handler for upload. A user can use file name as a property for a media library in custom plugin.
For example, to provide uniqueness of file names in a library. Only hash for this is not enough because it is random generated every time.
It would be awesome to see this getting merged. |
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
@AHgPuK I fixed the lint issues but the unit tests need to be fixed too. Can you do the change ? |
Exclude temporarily unit test 'Replaces reserved and unsafe characters for URLs and files in hash' because it did not work properly ever.
I fixed unit tests. |
Some E2E tests seem broken as well 😢 I have tested these changes on my project and so far everything works like a charm 🚀 |
@AHgPuK will you be able to take a look at it ? |
@alexandrebodin |
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.
LGTM, Thanks
@AHgPuK Can you fix the DCO check before we merge ? |
No, I'm not able to fix it. @alexandrebodin |
* Fix formatFileInfo Keep original file name including extension * Fix file name for generated media File name was not set for all generated media: thumbnail and resized pictures. * Generate hash based on file name without extension * cleanup PR Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com> * Fix unit tests Exclude temporarily unit test 'Replaces reserved and unsafe characters for URLs and files in hash' because it did not work properly ever. * Remove path delimiter from filename because it is correct character for file path * Fix e2e * Continue fixes for e2e * Fix createRequest content type * Correct thumbnail name in e2e test Co-authored-by: Alexandre BODIN <alexandrebodin@users.noreply.github.com> Co-authored-by: Alexandre Bodin <bodin.alex@gmail.com> Co-authored-by: Andrey Hohutkin <none@none> Signed-off-by: harimkims <harimkims@gmail.com>
* Fix formatFileInfo Keep original file name including extension * Fix file name for generated media File name was not set for all generated media: thumbnail and resized pictures. * Generate hash based on file name without extension * cleanup PR Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com> * Fix unit tests Exclude temporarily unit test 'Replaces reserved and unsafe characters for URLs and files in hash' because it did not work properly ever. * Remove path delimiter from filename because it is correct character for file path * Fix e2e * Continue fixes for e2e * Fix createRequest content type * Correct thumbnail name in e2e test Co-authored-by: Alexandre BODIN <alexandrebodin@users.noreply.github.com> Co-authored-by: Alexandre Bodin <bodin.alex@gmail.com> Co-authored-by: Andrey Hohutkin <none@none> Signed-off-by: Gil Fernandes <gil.fernandes@onepointltd.com>
Description of what you did:
Original file extension should not be replaced by mime type.
Also filename should include its extension (To keep compatibility for prior versions and having a minimal impact on existing providers)
Also it will allow to have filename without extension in specific cases when a user wish.
File name is added to generated media like thumbnails and resized pictures.
It is ready to be merged.