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
Fix invalid local uploads path #6925
Conversation
File upload provider does not consider the strapi configuration. This patch should fix the problem.
Fix invalid local uploads path
This will need to be checked against Mac and Linux |
@@ -23,6 +23,10 @@ module.exports = { | |||
}); | |||
} | |||
}; | |||
const getStaticPath = () => path.join( |
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.
this doesn't need to be a function. you can use
const uploadDir = path.join(strapi.dir, strapi.config.middleware.settings.public.path || strapi.config.paths.static)
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, Thank you 💯
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 couldn't push to the fork you made for some reason...
You will need to fix the tests in packages/strapi-plugin-upload/test/tests/bootstrap.test.js
set the globa.strapi like so:
global.strapi = {
dir: process.cwd(),
admin: {
services: { permission: { actionProvider: { register } } },
},
log: {
error() {},
},
config: {
get() {
return 'public';
},
paths: {},
info: {
dependencies: {},
},
},
plugins: {
upload: {
config: {
provider: 'local',
},
},
},
store() {
return {
get() {
return null;
},
set: setStore,
};
},
};
Please also use strapi.config.get('middleware.settings.public.path', strapi.config.paths.static)
to get the path :)
You mean services: { permission: { actionProvider: { register } } }, |
Codecov Report
@@ Coverage Diff @@
## master #6925 +/- ##
==========================================
- Coverage 26.17% 18.28% -7.90%
==========================================
Files 1130 1021 -109
Lines 15406 11895 -3511
Branches 2436 1704 -732
==========================================
- Hits 4033 2175 -1858
+ Misses 9557 8266 -1291
+ Partials 1816 1454 -362
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
@akcyp You need to update your branch (merge master) and then follow the previous comment ;) |
Thanks and forgive me for making corrections now, but I was on vacation. I hope everything will be ok now! 💯 😄 |
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 !
* Fix invalid local uploads path File upload provider does not consider the strapi configuration. This patch should fix the problem. * getStaticPath -> uploadDir * Use config.get method * plugin-upload tests fix Signed-off-by: Juan David <juand.business@gmail.com>
* Fix invalid local uploads path File upload provider does not consider the strapi configuration. This patch should fix the problem. * getStaticPath -> uploadDir * Use config.get method * plugin-upload tests fix Signed-off-by: Tomaszal <mrtomaszal@gmail.com>
Hi, with 3.0.* we had configured As a workaround, cloned the local provider (making a custom provider) and removed the strapi.dir prefix. But I'm not sure if this is the best approach. Is there a better way to configure an absolute path for the upload folder? |
@moritz-halke a fix is ready for the next release: #7280 |
* Fix invalid local uploads path File upload provider does not consider the strapi configuration. This patch should fix the problem. * getStaticPath -> uploadDir * Use config.get method * plugin-upload tests fix Signed-off-by: Gil Fernandes <gil.fernandes@onepointltd.com>
File upload provider does not consider the strapi configuration. This patch should fix the problem.
Description of what you did:
This configuration generates the following error when uploading the image:
The correct directory should be: