3

I'm using a NodeJS server. Currently I'm only checking if the uploaded file exists under the specified path. If it doesn't the server should return an error code.

I know it's not best practise to just check if it exists (it might be corrupted) but that's not the focus at the moment.

What status code does my server has to send when the file upload failed?

rrobben
  • 979
Wulthan
  • 43

1 Answers1

4

If you are programming a NodeJS server yourself you can decide what error code to return.

But you have to know what error code stands for what. e.x If I mail you about getting error code 406 you would have to know what error it could be.

For a user its easier to just return a message like "Error file uploading has failed please try again later." now the user knows whats wrong and won't bother you anymore.

In your code you can see / return specific messages for if there is a bug. Like "Error something went wrong please notify the system administrator about error code 406"

This way you know whats wrong with your code or where the error happend.

If you are talking about what HTTP error code you need to send you could read a documentation about it here

rrobben
  • 979