Skip to content
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

Merged
merged 12 commits into from Jun 25, 2020
Merged

Fixes for Media Library upload #5971

merged 12 commits into from Jun 25, 2020

Conversation

AHgPuK
Copy link
Contributor

@AHgPuK AHgPuK commented Apr 27, 2020

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.

Keep original file name including extension
File name was not set for all generated media: thumbnail and resized pictures.
@codecov
Copy link

codecov bot commented Apr 27, 2020

Codecov Report

Merging #5971 into master will increase coverage by 0.12%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            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              
Flag Coverage Δ
#front 14.67% <0.00%> (+<0.01%) ⬆️
#unit 41.69% <95.65%> (+0.42%) ⬆️
Impacted Files Coverage Δ
...-manager/admin/src/components/DynamicZone/index.js 0.00% <ø> (ø)
...lder/admin/src/containers/FormModal/utils/forms.js 0.00% <0.00%> (ø)
.../containers/InputModalStepper/InputModalStepper.js 0.00% <ø> (ø)
...-upload/admin/src/containers/ModalStepper/index.js 0.00% <ø> (ø)
...-permissions/admin/src/components/ListRow/index.js 0.00% <ø> (ø)
...rmissions/controllers/validation/email-template.js 95.00% <95.00%> (ø)
packages/strapi-plugin-upload/services/Upload.js 17.03% <100.00%> (-0.62%) ⬇️
...trapi-admin/admin/src/containers/AuthPage/index.js 0.00% <0.00%> (ø)
...rapi-plugin-upload/admin/src/translations/index.js 0.00% <0.00%> (ø)
...rmissions/admin/src/components/Controller/index.js 0.00% <0.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce27609...868a3dd. Read the comment docs.

@alexandrebodin alexandrebodin added source: core:upload Source is core/upload package issue: enhancement Issue suggesting an enhancement to an existing feature labels May 12, 2020
@@ -42,6 +42,7 @@ const generateThumbnail = async file => {
const { width, height, size } = await getMetadatas(newBuff);

return {
name: `thumbnail_${file.name}`,
Copy link
Member

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 ?

Copy link
Contributor Author

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.

@ghost
Copy link

ghost commented Jun 15, 2020

It would be awesome to see this getting merged.
The behavior of changing file extensions to .bin broke our whole application stack as we have several APIs expecting to find a specific extension.
Yes, being dependent on a specific extension is not great but we work with third-party programs on which we have no control, so really we have no choice.
Do you plan to get this fixed soon?
I would be interested in getting more context on what drove the Strapi team to chose such behavior of transforming the file extension.

@alexandrebodin
Copy link
Member

@AHgPuK I fixed the lint issues but the unit tests need to be fixed too. Can you do the change ?

Andrey Hohutkin added 2 commits June 16, 2020 00:11
Exclude temporarily unit test 'Replaces reserved and unsafe characters for URLs and files in hash' because it did not work properly ever.
@AHgPuK
Copy link
Contributor Author

AHgPuK commented Jun 15, 2020

@AHgPuK I fixed the lint issues but the unit tests need to be fixed too. Can you do the change ?

I fixed unit tests.

@ghost
Copy link

ghost commented Jun 15, 2020

Some E2E tests seem broken as well 😢
https://travis-ci.org/github/strapi/strapi/jobs/698708199#L8124

I have tested these changes on my project and so far everything works like a charm 🚀

@alexandrebodin
Copy link
Member

@AHgPuK will you be able to take a look at it ?

@AHgPuK
Copy link
Contributor Author

AHgPuK commented Jun 20, 2020

@alexandrebodin
I fixed e2e tests

@alexandrebodin alexandrebodin added this to the 3.0.6 milestone Jun 24, 2020
Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks

@alexandrebodin
Copy link
Member

@AHgPuK Can you fix the DCO check before we merge ?

@AHgPuK
Copy link
Contributor Author

AHgPuK commented Jun 24, 2020

No, I'm not able to fix it. @alexandrebodin
There was a merge with source master and git rebase fails on it.

@alexandrebodin alexandrebodin merged commit 94e031e into strapi:master Jun 25, 2020
iicdii pushed a commit to iicdii/strapi that referenced this pull request Jul 2, 2020
* 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>
gilfernandes pushed a commit to onepointconsulting/strapi that referenced this pull request Aug 13, 2020
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature source: core:upload Source is core/upload package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants