Reputation: 18827
I'm using AFHTTPClient
to connect to my backend server to upload an image using multipartFormRequestWithMethod
. I'm testing the request in an iPhone app with the network conditioner using the Very Bad Network
setting, this means that the request takes much longer than usual.
To avoid showing the activity indicator for ever I cancel the request after 30 seconds. In the very bad network scenario this means that:
In the second case the server has received the information and therefore stores it in the database but the client receives an error (the operation being cancelled) and therefore the user can try to upload the image again later which will result in having the same image twice.
If, I knew when the request has reached the server I could then avoid posting two times the same image.
How can I check if the server has received a request?
Upvotes: 0
Views: 1713
Reputation: 42588
There really is only one way to know if the server has completed a previous request, ask the server if it has the content.
Before making the second PUT/POST, make a HEAD request for the URL you expect the image to be at to see if it exists.
Upvotes: 2