-
Notifications
You must be signed in to change notification settings - Fork 66
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
Use absolute paths for uploads and db #168
Conversation
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.
It is better to leave it possible to specify the relative path.
As a solution, you can check for /
at the beginning of the path
src/backend/controllers/transport.ts
Outdated
}); | ||
|
||
await file.save(); | ||
|
||
let response = file.data; | ||
|
||
console.log(file) |
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.
logs
src/backend/models/file.ts
Outdated
@@ -10,6 +10,7 @@ const filesDb = database['files']; | |||
* @property {string} filename - name of uploaded file | |||
* @property {string} path - path to uploaded file | |||
* @property {string} mimetype - file MIME type | |||
* @property {string} url - file url |
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 description is not clear. Where is the URL got from?
@@ -77,10 +77,17 @@ router.post('/transport/image', imageUploader, async (req: Request, res: Respons | |||
return; | |||
} | |||
|
|||
const fileData = { | |||
...req.files.image[0], | |||
url: '/uploads/' + req.files.image[0].filename, |
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.
why do we need to hardcode the URL at the Database instead of using the file id of the 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.
because all static files are serving from uploads directory
before this change file url depends on uploads folder name, which is wrong
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.
but why do we need to store the /uploads/
at the db? What if we will change it in the future? I think we can compose the URL on the fly by the client-side app.
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 guess you're right, we can resolve it in the separate issue
With this change I just resolve issue when uploads stores in folder with different name
@@ -8,6 +8,9 @@ | |||
<p> | |||
Enter a password to access pages editing | |||
</p> | |||
<p> | |||
{{ header }} |
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.
what is it?
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.
Alexander made it to see what error occurs
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.
Fix is ok. The hardcode should be removed due tu #184
resolves #25