0

I have an image that I'm getting ready to upload. I know that I can download it and store it in the AFNetworking NSURLCache I already have, but I already know the what the url will be before I upload it so I want to cache it before I upload it using AFNetworking's NSURLCache.

How can I cache something in NSURLCache without it being downloaded aka an NSURL response? Or can I create an NSURLResponse from a local download aka within the application?

I dont want to have to download it if i'm the user that uploaded it. Also i want to utilize AFNetworking's cache (NSURLCache) before i separately create my own.

Here is how AFNetworking's NSURLCache works under the hood: AFNetworking's NSURLCache

I'm using the latest version of AFNetworking: enter image description here

ian
  • 1,002
  • 2
  • 12
  • 29
  • from where you are going to upload and to which place. from your app to the server ? – Shubhank May 01 '16 at 17:49
  • Yes I'm uploading the image from my device to my AWS S3 bucket, but I want to cache it prior so when i go to download images later, if its my image, just grab it from the cache instead of downloading it – ian May 01 '16 at 17:50
  • you need to tell which afnetworking version you are using – Shubhank May 01 '16 at 17:54
  • @Shubhank Please see my updated answer per your request. I'm using the latest version - pod v3.1.0 – ian May 01 '16 at 18:02
  • https://github.com/AFNetworking/AFNetworking/blob/32cf30a2451917c25d853fccb9e112b64415595e/UIKit%2BAFNetworking/AFAutoPurgingImageCache.m#L110 You can see this function which actually caches the thing. you need to just pass your request url and it will cache along that string – Shubhank May 01 '16 at 18:09
  • Wow! thats so straight forward. How can I do that with videos? – ian May 01 '16 at 18:24
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/110848/discussion-between-user2792129-and-shubhank). – ian May 02 '16 at 16:06

0 Answers0