mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Update index.js
the public folder shouldn't be hard-coded, it needs to follow the "strapi.config.public.path" value.
I faced this issue on my current project where i have a custom path for the "public" folder for development, replacing:
```
path.join(strapi.config.appPath, 'public', `uploads/${file.hash}${file.ext}`)
```
with
```
path.join(strapi.config.public.path, `/uploads/${file.hash}${file.ext}`)
```
solved my problem, so i need to notify you on this issue.
This commit is contained in:
parent
3d7fa99807
commit
f9bc0a9b2e
@ -16,7 +16,7 @@ module.exports = {
|
||||
upload: (file) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// write file in public/assets folder
|
||||
fs.writeFile(path.join(strapi.config.appPath, 'public', `uploads/${file.hash}${file.ext}`), file.buffer, (err) => {
|
||||
fs.writeFile(path.join(strapi.config.public.path, `/uploads/${file.hash}${file.ext}`), file.buffer, (err) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
@ -29,7 +29,7 @@ module.exports = {
|
||||
},
|
||||
delete: (file) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const filePath = path.join(strapi.config.appPath, 'public', `uploads/${file.hash}${file.ext}`);
|
||||
const filePath = path.join(strapi.config.public.path, `/uploads/${file.hash}${file.ext}`);
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return resolve('File doesn\'t exist');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user