1

How Can I Get Remote FileName on Host When download it via ASIHttpRequest??

for example, some url like this:

http://www.filedropper.com/processing/filedownload.php?id=test_22

test_22 is my filename, but original string is @"test_22.gif" , i can not analysis the filename extension from url.

i am trying to get responseString for the real filename when ASIHttpRequest call it delegate method :

- (void)request:(ASIHTTPRequest *)request
    didReceiveResponseHeaders:(NSDictionary *)responseHeaders

but i got nothing useful.

any idea?

Ron
  • 89
  • 7
  • See if the response headers include `Content-Disposition` or `Content-Location`. –  Apr 20 '11 at 05:34

1 Answers1

0

i hope, you can get file name through the following code..see the link to find file type.after finding append it..

 NSString *url = @"http://www.filedropper.com/processing/filedownload.php?id=test_22";
 NSArray *parts = [url componentsSeparatedByString:@"="];
 NSString *filename = [parts objectAtIndex:[parts count]-1]; // or NSString *filename = [parts lastObject]; 
Community
  • 1
  • 1
  • but original string is @"test_22.gif" – Ron Apr 20 '11 at 04:48
  • did u try NSString *filename = [parts lastObject]; –  Apr 20 '11 at 04:52
  • it returns @"test_22", but i need is @"test_22.gif" – Ron Apr 20 '11 at 04:54
  • dont give down vote if answer is not satisfied to you...you should find out the text after "." which comes after "=",and then you should append it ...this is a help.. –  Apr 20 '11 at 05:07