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

Supporting URLRequest in inline image download #59

Open
rizwan95 opened this issue Feb 26, 2020 · 11 comments
Open

Supporting URLRequest in inline image download #59

rizwan95 opened this issue Feb 26, 2020 · 11 comments

Comments

@rizwan95
Copy link

rizwan95 commented Feb 26, 2020

Hi, is there any way to add URLRequest in the inline image download method? @indragiek

@rizwan95 rizwan95 changed the title Adding custom headers to URLSession download task Supporting URLRequest in inline image download Feb 26, 2020
@jlj
Copy link
Contributor

jlj commented Feb 26, 2020

Hi @rizwan95,
Currently the image download is handled by a simple download task and only a base URL can be configured (typically for images using relative links).

Could you provide more information about your use case, and about the type of URLRequest customization you would need?

@rizwan95
Copy link
Author

@jlj Sometimes we might need to send additional headers like user-agent and authorization headers for downloading images from authenticated services. So, it would be very helpful if there is a way to send them.

@rizwan95
Copy link
Author

@jlj Any update on this?

@jlj
Copy link
Contributor

jlj commented Mar 19, 2020

A possible option could be to add a imageURLSession property of type NSURLSession in CMAttributedStringRenderer. If set, this imageURLSession property would then be used to retrieve every remote image referenced by the current document.

At creation time, the imageURLSession property could receive any desired NSURLSessionConfiguration, providing thus a high level of customizability to image download.

@rizwan95 Would this solution respond to your needs?

@rizwan95
Copy link
Author

@jlj : Yes, that would solve the problem! Infact it will open up a lot of opportunities for customizability.

@jlj
Copy link
Contributor

jlj commented Mar 20, 2020

@rizwan95 I have implemented this imageURLSession property change in my CocoaMarkdown fork at https://github.com/jlj/CocoaMarkdown/tree/5512cf52d292288e1748e7bde097e5b28a7e52b6

Can you test it with your specific server configuration? If it is ok, I will issue a pull request.

@rizwan95
Copy link
Author

@jlj Yes sure!

@jlj
Copy link
Contributor

jlj commented Apr 2, 2020

@rizwan95 Have you made tests of this imageURLSession property?

@rizwan95
Copy link
Author

rizwan95 commented Apr 3, 2020

Not yet, I will test it today and let you know @jlj Sorry for the delay!

@jlj
Copy link
Contributor

jlj commented Apr 16, 2020

@rizwan95 Any test result?

@rizwan95
Copy link
Author

rizwan95 commented Oct 1, 2020

Hi @jlj I tested the given patch. It is not rendering basic markdown content itself. :(
I suppose something is broken..

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