I'm developing a REST API and I have some file uploads:
PHP can generate an UPLOAD_ERR_PARTIAL
error when the file was only partially uploaded, and I'm not sure of which HTTP status code should be used in this case.
This usually happens if the user cancels the upload (see Why might a file only be partially uploaded and file upload errors on php.net )
UPLOAD_ERR_PARTIAL is given when the mime boundary is not found after the file data. A possibly cause for this is that the upload was cancelled by the user (pressed ESC, etc).
i think the header should be based on error context:
if the file upload is not an allowed type:
if the file upload it too big:
if the server has a problem w/ the upload:
if the upload times out:
but in general, i would say that 500 is pretty standard.
You should use 409 status code for this case.
According to http://www.ietf.org/rfc/rfc2616.txt:
The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where
it is expected that the user might be able to resolve the conflict
and resubmit the request. The response body SHOULD include enough
information for the user to recognize the source of the conflict.
Ideally, the response entity would include enough information for the user or user agent to fix the problem; however, that might not be
possible and is not required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With