Closed zephyrpathsofglory closed 1 year ago
@zephyrpathsofglory, Have you made sure you passed in the file? If possible, can you send me the request body so that I can better locate the error. Thanks your issue!
@zephyrpathsofglory, Have you made sure you passed in the file? If possible, can you send me the request body so that I can better locate the error. Thanks your issue!
This is the request body:
It seems that my file has not uploaded?
It is weird that it shows only .md type files are allowed to be uploaded
but what I uploaded is a md file.
This is the request body:
It seems that my file has not uploaded?
Yes you are not passing file in your request body. I'm curious how this happens, because in the front-end form, the upload button cannot be clicked without selecting a file.
You can try to pull the latest code, and then try to upload note to see if this happens again. it's really weird.
I have pulled the latest code, rebuilt the docker images, and restarted the docker-compose servers. But still got the same error.
I have pulled the latest code, rebuilt the docker images, and restarted the docker-compose servers. But still got the same error.
okay, I think the problem should be in the frontend, give me some time to find where the problem is.
@zephyrpathsofglory, hi, I should know what the problem is, is the MIME type of the file you uploaded text/markdown
or text/x-markdown
? It will report an error if you don't upload the exact file type. Of course I'm sorry for not terminating subsequent operations when uploading the wrong file.
The uploaded file is a README file with md extension downloaded from github. The mime type of this file is text/html
(get by executing file --mime-type -b $file
)
Yeah its not allowed. detectLegalFile You can see the logic in this code. I have modified the logic of not terminating the upload after reporting an error and will update it immediately.
Yeah its not allowed. detectLegalFile You can see the logic in this code. I have modified the logic of not terminating the upload after reporting an error and will update it immediately.
Why not check file type by file extensions?
Yeah its not allowed. detectLegalFile You can see the logic in this code. I have modified the logic of not terminating the upload after reporting an error and will update it immediately.
Why not check file type by file extensions?
Because MIME types provide more accurate information about the file's content, are more secure, have better cross-platform compatibility, and are less susceptible to manipulation by malicious users.
Yeah its not allowed. detectLegalFile You can see the logic in this code. I have modified the logic of not terminating the upload after reporting an error and will update it immediately.
Why not check file type by file extensions?
Because MIME types provide more accurate information about the file's content, are more secure, have better cross-platform compatibility, and are less susceptible to manipulation by malicious users.
Thank you, but not all md file is text/markdown. It will fail the upload with a good chance.
What you said is correct. I will add more type judgments after trying it later. Thank you very much for your issue and follow! If you have any suggestions in the future, you can also submit an issue or PR ~
Description of the bug
I uploaded a
md
file but the server returned 500, and the following is the log of server:Environment: