Fetch from disk instead of remote url
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 ?
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).
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!
Hi, check out Usage guide. You can use all the same APIs that you use for loading remote images for fetching images from disk.