0

I've been trying for 2 days and cant figure this out.

Basically I have a URL and I try to download the file that associate with it using ASIHTTPRequest, but the URL I have is not the link of the file itself, but that URL will redirect to the link of the actual file. I try to give that link to ASIHTTPRequest for download, but it didn't. SO I think I have to somehow get the redirected url and feed that to ASIHTTPRequest to download the file.

How can I do this?

Thanks all for reading :)

Kyle Mai
  • 133
  • 2
  • 14

1 Answers1

0

You implement this delegate method of ASIHTTPRequest - (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL the Method is called, but after the request isn't redirected as I asumed. You have to redirect the request by yourself:

  - (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL 
  {
   // modify request here, e.g. set request headers again...
   [request redirectToURL:newURL];
  }
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
  • Turns out, the URL downloaded just fine even though it redirected to the file. I jailbroke my phone and found out that the file downloaded into a different name, so all I have to do is fix the naming method. But I think others will gain from your answer. Thanks for helping out :) – Kyle Mai May 31 '12 at 02:48