1
votes

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?

1
See if the response headers include Content-Disposition or Content-Location.user557219

1 Answers

0
votes

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];