Hej,
is there an easy way to check if a file to be downloaded is newer than the locally existing one?
Cheers,
Phil
Hej,
is there an easy way to check if a file to be downloaded is newer than the locally existing one?
Cheers,
Phil
There is no easy way that I know of. I had a need for something like this and had to do the following:
send time stamp of file from server to app
compare time stamp to local copy of file in app
start download if local copy was older than server copy
Also had to make sure time stamps were correctly adjusted for app and server being in different time zones.
Don’t HTTP HEAD requests support timestamps? I can’t remember whether I’ve used this in Corona; if it supports it, you may want to try it.
This is what HTTP’s HEAD verb is for. It’s like the same as GET but without transferring the actual content. You will get all of the header’s which includes information on when it was last updated.
Rob
Thanks for the responses,
when I try network.request(…, “HEAD”, …)
I dont get anything even for event.ResponseHeaders[“Content-Type”]. It just doesnt execude the networkListener
Also what would the timestamp of the file be instead of “Content-Type”?
Cheers,
Phil
I would use a table printing function such as those listed here: http://coronalabs.com/blog/2014/09/02/tutorial-printing-table-contents/
and print out the event.response table and see what values are there for you to use.
Rob
There is no easy way that I know of. I had a need for something like this and had to do the following:
send time stamp of file from server to app
compare time stamp to local copy of file in app
start download if local copy was older than server copy
Also had to make sure time stamps were correctly adjusted for app and server being in different time zones.
Don’t HTTP HEAD requests support timestamps? I can’t remember whether I’ve used this in Corona; if it supports it, you may want to try it.
This is what HTTP’s HEAD verb is for. It’s like the same as GET but without transferring the actual content. You will get all of the header’s which includes information on when it was last updated.
Rob
Thanks for the responses,
when I try network.request(…, “HEAD”, …)
I dont get anything even for event.ResponseHeaders[“Content-Type”]. It just doesnt execude the networkListener
Also what would the timestamp of the file be instead of “Content-Type”?
Cheers,
Phil
I would use a table printing function such as those listed here: http://coronalabs.com/blog/2014/09/02/tutorial-printing-table-contents/
and print out the event.response table and see what values are there for you to use.
Rob