Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I download big image without crash #90

Open
smolskyaleksey opened this issue Feb 6, 2019 · 5 comments
Open

Can I download big image without crash #90

smolskyaleksey opened this issue Feb 6, 2019 · 5 comments

Comments

@smolskyaleksey
Copy link

If I download big image via

self.session.dataTask(with: request, completionHandler: { [weak self] data, response, error}

image stored inside response. And I can catch crash. How can I use URLSession's method

func downloadTask(with request: URLRequest, 
completionHandler: @escaping (URL?, URLResponse?, Error?) -> Void) -> URLSessionDownloadTask

to store image in file

@3lvis 3lvis closed this as completed Jun 7, 2020
@smolskyaleksey
Copy link
Author

Why do you close issue without any answer?

@3lvis
Copy link
Collaborator

3lvis commented Jun 7, 2020

Hello @smolskyaleksey,

Sorry for not writing before. I haven't been able to reproduce this issue. Could you help me with additional steps to reproduce? How big was the file you were trying to download? Is this still an issue for you?

@smolskyaleksey
Copy link
Author

Yes, try to download big image above 100 mgb. dataTask represent image in memory in data parameter. U can crash because you don't have enough memory.

@3lvis
Copy link
Collaborator

3lvis commented Jun 8, 2020

OK! Will try to reproduce, this might be caused because of limitations in URLSession so it might require us to implement background downloads in order to make this work. WIll investigate further.

@3lvis 3lvis reopened this Jun 8, 2020
@smolskyaleksey
Copy link
Author

OK! Will try to reproduce, this might be caused because of limitations in URLSession so it might require us to implement background downloads in order to make this work. WIll investigate further.

You can use

func downloadTask(with request: URLRequest, 
completionHandler: @escaping (URL?, URLResponse?, Error?) -> Void) -> URLSessionDownloadTask

It downloads file directly in file system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants