2

I'm using an NSURLConnection to download from an FTP site. the download is fine but I want only to download if the ftp server copy is newer than my file copy.

how do i get the ftp file date info from the ftp server. I am able to get the file size from the URLResponse.

Best regards,

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
MB.
  • 723
  • 1
  • 11
  • 28

2 Answers2

2

Ok Folks I have partially answered my own question so this is for the next guy...

if you issue an NSURL request for the folder the resulting response will be the list of files. the problem is that the format for the date time stamp is not what i need.

-rw-r--r-- 1 1012 1012 1899 Feb 03 01:14 1.txt

I need a full YY-MM-DD HH:MM:SS format is there anyway i can configure the url request to give me the full string as if I had issued a "LIST -a" command to the server.

MB.
  • 723
  • 1
  • 11
  • 28
  • I used this capability as a workaround: After download just store the result of the NSURL request for the folder in an NSString. Then before download compare the stored string to the result of the NSURL request for the folder again. If the strings don't match, I am sure the directory on the server changed and needs downloading. No parsing of the awkward date format is needed for that. – Bjinse Jul 31 '12 at 09:17
0

You using ftp? Really? With username and password? Unless your server is well configured, FTP is a security hole waiting to happen.

However, the best solution would be to use HTTP to communicate between your app and a server. HTTP support is built in, HTTP is ubiquitous, and it is much easier to configure a web server to be secure. Also there is a last-modified header in HTTP which could help you figure out server copy is newer than local file copy

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
  • Yeah, I Know not happy about it but i can't change that right now. I use last modified elsewhere as I am able to use https. On this project though I have no choice but to use an ftp server at present – MB. Feb 02 '12 at 16:15
  • OK I found a way to do it and even better the client has decided to take my advice and go https.... will post code when i can – MB. Feb 10 '12 at 20:50