Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I pass headers to an image source?

Tags:

react-native

My image-source is secured, so ideally I would like to do the following:

<Image source={{uri: "http://path/to/image", 
                headers: {Authorization: 'Bearer ' + this.props.bearerToken}}}/> 

Is there anyway I can approximate that, short of loading the image into Javascript and rendering the image from there?

like image 326
Michael Lorton Avatar asked May 11 '16 00:05

Michael Lorton


People also ask

How do I add a header to an image?

Go to Insert > Header or Footer > Blank. Double-click Type here in the header or footer area. Select Picture from File, choose your picture, and select Insert to add the picture.

How do I give an image a source?

To use an image on a webpage, use the <img> tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load.

Which attribute is used in image source?

The required src attribute specifies the URL of the image.


2 Answers

React naitve supports adding header or body in requesting image. UPDATED: See this.

 <Image source={{
      uri: 'https://facebook.github.io/react/img/logo_og.png',
      method: 'POST',
      headers: {
        Pragma: 'no-cache'
      },
      body: 'Your Body goes here'
    }}
    style={{width: 400, height: 400}} />
like image 174
Aung Myat Hein Avatar answered Oct 03 '22 05:10

Aung Myat Hein


This capability has recently been merged into React-Native: https://github.com/facebook/react-native/pull/7338/files

like image 6
Shaheen Ghiassy Avatar answered Oct 03 '22 05:10

Shaheen Ghiassy