开发者

Get File Size of File to download using FTP

I am using the simpleFTPsample of apple. I want to display a progress bar of the file being downloaded. I understand it needs to be done in:

- (void)st开发者_StackOverflowream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode

under the case:

case NSStreamEventOpenCompleted:

how do i retrive the file size from the NSInputStream?

I have also tried:

i have set:

[self.networkStream setProperty:@"YES" forKey:(id)kCFStreamPropertyFTPFetchResourceInfo];

and then:

NSLog(@"size: %@",[self.networkStream propertyForKey:(id)kCFStreamPropertyFTPResourceSize]);

but the result is null...


You will have to set kCFStreamPropertyFTPFetchResourceInfo to true. That way the CFFTPStream will send a STAT command to the FTP server to get file info, including the total size.


To get the file size you just need:

case NSStreamEventOpenCompleted: {
      fileSize = [[self.networkStream propertyForKey:(id)kCFStreamPropertyFTPResourceSize] integerValue];}

By the way do you know how to get the modification date of the file in the ftp server??

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜