Nuke icon indicating copy to clipboard operation
Nuke copied to clipboard

Fetch from disk instead of remote url

Open rakeshpethani opened this issue 10 years ago • 3 comments

Hi,

I have been trying to load image from documents directory but it gives me "Unsupported url" error.

Is it supported by the library to load image from file (local) url rather than from remote (server) url ?

rakeshpethani avatar Nov 09 '16 13:11 rakeshpethani

Hey,

Yes, it is supported. Nuke uses NSURLSession under the hood and it supports file:// scheme which works with local files:

The NSURLSession class natively supports the data, file, ftp, http, and https URL schemes

I've just tested it to make sure:

func testFileUrl() {
    let bundle = Bundle(for: LoaderTests.self)
    let url = bundle.url(forResource: "Image", withExtension: "jpg")!

    expect { fulfill in
        Loader.shared.loadImage(with: url).completion { response in
            print(response)
            fulfill()
        }
    }
    wait()
}

Make sure that your urls have a valid format (including scheme).

kean avatar Nov 09 '16 13:11 kean

Hi. Please help me.

Loader.shared.loadImage(with: urlVal)
.then({ (image) in
....
})

error: missing argument for parameter 'token' in call

i inserted "CanecllationTokenSource().token", but it not work

Thanks!

AlexLee9986 avatar Feb 28 '17 02:02 AlexLee9986

Hi, check out Usage guide. You can use all the same APIs that you use for loading remote images for fetching images from disk.

kean avatar Feb 28 '17 08:02 kean