Cant find any documentation on how server should return errors.
If the server returns JSON, it will be parsed for error messages as well
What the structure of response JSON should be?
This does not work
{
error: "Files with such extension is not allowed"
}
You should return a string with content type "application/json".
Rails example:
format.json do
if item.save
render nothing: true
else
# return error
render text: "\"#{item.errors.full_messages.first}\"", status: 422
end
end
I'm not asking HOW it shuld render result, but instead i want to know WHAT!
This code tells me nothing, as i know nothing about rails...
PS: I have moved to jQuery file uploader
Simply return the text as error.
Oh my god... REALLY???
You still doesn't unswer my question!!!
I asked response format you give me some rails code... Than i asked response format again, and you say "return the text as error", maybe you was try to say "return the error as text"??? or you was try to explain this response format {"error": text}, or may be this: {"text": error}, or may be this: "text", or this: ["text"].
AMAZING!
You still doesn't unswer my question!!!
What the fuck dude.
Same question.
I guess i found most inadequate developers in the world...
Response example: "Something went wrong"
On Friday, December 6, 2013, USvER wrote:
Same question.
I guess i found most inadequate developers in the world...—
Reply to this email directly or view it on GitHubhttps://github.com/enyo/dropzone/issues/372#issuecomment-29992875
.
Nihad Abbasov
At last, thank you...
This is not JSON... This is not what @enyo said!...
lol dude... @USvER chill...
First off, you're using an open source software at no charge, where people are kind enough to take the time to try and answer your question. If the answer is not as detailed as you'd hoped, sorry, but please stay polite. I receive more than 10 support requests per day concerning Dropzone, and it might surprise you, but this is not my main job.
You can simply return the text as error message with content-type text/plain. Example: Something went wrong., or as JSON with content-type application/json, example "Something went wrong". If you also return an error code (example 500) Dropzone will know something went wrong and display it.
I think the documentation you're referring to:
If the server returns JSON, it will be parsed for error messages as well
is incorrect at the moment. Although the returned JSON will be parsed, it will not look for an error key. I'll create an issue for that.
Issue #411
Sorry for not being polite... But my question was reasonable and clear... and instead of getting clear answer like this: "To report error message from server you can respond with plain text or json string" first i got some code that i don't understand, and i was polite and asked my question again.. when i got totaly unclear unswer from you i was pissed... again... sorry for that...
PS this is nothing to do with opensource, just miscommunication i guess
In the future just keep in mind that the people working on open source projects and giving support do it in their spare time without compensation. Getting rude replies when trying to help some random stranger (even if it didn't seem helpful to you) is very discouraging.
@enyo I think, it should be added to wiki https://github.com/enyo/dropzone/wiki/FAQ#how-to-show-an-error-returned-by-the-server
Btw, thanks for awesome work :smile:
@NARKOZ Thank you! I updated it.
Thank you! Good job...
Sorry for writing in such an old thread but I think my question will fit for this topic.
What's the best way, to pass an error to the client, if there are multiple files but only 1 has an error?
At the moment I set the HTTP-Status-Code in case of error and pass some JSON to the client. The problem is, that when I have one error, all files will be displayed with an error in Dropzone.
I'm processing the files in a loop and pass the result (if successful or not) to the client by PHP echo. Is there a better way of doing this?
Thanks in advance for your help.
@csteinle92 I don't think you can. I have the same issue, and basically solved the problem by setting
parallelUploads: 1,
uploadMultiple: true
Which is a workaround, not a solution
@robmuld thanks for your reply :) This could indeed be used as a workaround.
But the user has to click "Upload" for every single file. This could be annoying after some time. Nevertheless I will keep this as a temporary solution.
So, I, in 2017 was still having this issue, I could see in the source that the error function was checking for the error key in the returned json, but it still didn't work..my solution is at this link. I had to edit the source, but it works great.
https://github.com/enyo/dropzone/issues/411#issuecomment-316765948
I hope this helps someone out.
Most helpful comment
lol dude... @USvER chill...
First off, you're using an open source software at no charge, where people are kind enough to take the time to try and answer your question. If the answer is not as detailed as you'd hoped, sorry, but please stay polite. I receive more than 10 support requests per day concerning Dropzone, and it might surprise you, but this is not my main job.
You can simply return the text as error message with content-type
text/plain. Example:Something went wrong., or as JSON with content-typeapplication/json, example"Something went wrong". If you also return an error code (example500) Dropzone will know something went wrong and display it.I think the documentation you're referring to:
is incorrect at the moment. Although the returned JSON will be parsed, it will not look for an error key. I'll create an issue for that.