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

Use absolute paths for uploads and db #168

Merged
merged 9 commits into from
Apr 22, 2022
Merged

Use absolute paths for uploads and db #168

merged 9 commits into from
Apr 22, 2022

Conversation

n0str
Copy link
Member

@n0str n0str commented Apr 10, 2022

resolves #25

@n0str n0str marked this pull request as ready for review April 10, 2022 11:31
Copy link
Member

@nikmel2803 nikmel2803 left a 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

});

await file.save();

let response = file.data;

console.log(file)
Copy link
Member

Choose a reason for hiding this comment

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

logs

@@ -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
Copy link
Member

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,
Copy link
Member

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?

Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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 }}
Copy link
Member

Choose a reason for hiding this comment

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

what is it?

Copy link
Member

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

src/backend/app.ts Show resolved Hide resolved
Copy link
Member

@neSpecc neSpecc left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Database is in an unexpected place
3 participants