nativescript-community / ui-image

Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.
Apache License 2.0
36 stars 9 forks source link

Ability to add headers to request #57

Closed Logikgate closed 3 months ago

Logikgate commented 3 months ago

This adds a headers prop that allows a user to specify custom headers to be sent with the image download request. It is especially useful for sending authentication headers.

I added this so that I could migrate from nativescript-image-cache-it which has this functionality but has recently begun to crash our app. I only implemented for iOS since I'm not very familiar with Android development

farfromrefug commented 3 months ago

@Logikgate looks nice. we can implement the android as it is done in RN I am ok looking at it but i need a sample url which would need a header. Do you have that?

Logikgate commented 3 months ago

I don't have one off hand, I just tested using our app which requires auth headers for all image requests. I'll try to find a publicly available way to test this.

Logikgate commented 3 months ago

@farfromrefug I found a free image service that requires an authorization header to be sent with requests:

https://pexels.com

If you have an api key a get request to https://api.pexels.com/v1/photos/2014422 with the header of {Authorization: API_KEY} will get the image. If you don't have the header it will fail.

I can send you privately my api key I just generated if you'd like or you can create a free account there. Just let me know.

farfromrefug commented 3 months ago

@Logikgate if you can share a key on discord would be perfect. Would prefer not to have to create an account