react-native-fast-image icon indicating copy to clipboard operation
react-native-fast-image copied to clipboard

Not able to load images from Amazon s3 bucket

Open snuzi opened this issue 8 years ago • 16 comments

Hi there, FastImage is not able to load image from Amazon S3 bucket. The image is public and ContentType image/jpeg. Does anyone faced this issue before? I would appreciate if someone can help me with a workaround.

Thanks.

snuzi avatar Jun 04 '18 17:06 snuzi

I am loading lots of images from S3 without any issues. Can you give more information? A link to one of those images could be helpful!

n1ru4l avatar Jun 05 '18 13:06 n1ru4l

Hi @n1ru4l https://s3.eu-central-1.amazonaws.com/megroplan-test/recipe/1528058084_BuNpnvWM44.jpeg

The image is displayed using from React Native.

I have a Flatlist and below is my render item:

Please find the code in the link because inserting as code gets broken here: https://docs.google.com/document/d/1rmddkPH6kH831VjHeyR_n2KG5bNE2q2banPnAcXSwbg/edit

bfdevelop avatar Jun 05 '18 13:06 bfdevelop

@bfdevelop Are you able to load other images, beside those from your s3 bucket?

n1ru4l avatar Jun 05 '18 14:06 n1ru4l

@n1ru4l Yes, I can load other images, even large images. You did not use any special properties, right?

bfdevelop avatar Jun 05 '18 14:06 bfdevelop

@bfdevelop Did you resolve the issue? If so please comment your solution for other users that experience this issue!

n1ru4l avatar Jun 06 '18 15:06 n1ru4l

Someone else had an issue similar to this and they found they had some kind of user agent check preventing the image from loading.

DylanVann avatar Jun 07 '18 17:06 DylanVann

I have the same issue the images not load for aws services. is there any solution..?

brayanL avatar Apr 22 '19 21:04 brayanL

I too have the same issue, I am passing sample image uri's in the fast-image tag and rendering it. But no Images are displayed. Below is the code:

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import FastImage from 'react-native-fast-image'


const YourImage = () => (
  console.log("this is called"),
  <FastImage
      style={styles.image}
      source={{
          uri: "https://luehangs.site/pic-chat-app-images/animals-avian-beach-760984.jpg",
          headers: { Authorization: 'someAuthToken' },
          priority: FastImage.priority.normal,
      }}
      resizeMode={FastImage.resizeMode.contain}
  />
)



export default YourImage;

abhirup03 avatar Apr 24 '19 05:04 abhirup03

I am not loading any images from S3. All i am doing is passing a sample image Uri, but all i see is a blank screen.

abhirup03 avatar Apr 24 '19 06:04 abhirup03

I am not loading any images from S3. All i am doing is passing a sample image Uri, but all i see is a blank screen.

You need remove this string headers: { Authorization: 'someAuthToken' }

This work for me.

Desteel avatar Dec 20 '19 10:12 Desteel

Any solution here?

zach-luman avatar Apr 22 '20 07:04 zach-luman

any updates?

arashkevich25 avatar Apr 23 '20 18:04 arashkevich25

See https://github.com/DylanVann/react-native-fast-image/issues/242#issuecomment-638732002 for some ideas on things to try.

andreialecu avatar Jun 04 '20 10:06 andreialecu

If your backend is validating user-agent for the authorization token, check if the user-agent used for generating auth token is same for fast image as well.

In my case setting the right user-agent fixed the problem.

import { getUserAgent, getUserAgentSync } from 'react-native-device-info';
const source = {
   uri: 'http://yoururl',
    headers: {
        Authorization: `Bearer ${TokenService.getValidAccessTokenSync()}`,
        'user-agent': getUserAgentSync()
      },
}

aerolalit avatar Jun 09 '20 20:06 aerolalit

Please try this format may be it works

<FastImage key={idx} src={{ uri: 'http://yoururl' + '?noCache=' + Math.random().toString(), method: 'GET', headers: { 'Access-Control-Allow-Origin': '*'}, body: '' }} />

Herry-Lab avatar Jun 29 '20 13:06 Herry-Lab

Please try this format may be it works

<FastImage key={idx} src={{ uri: 'http://yoururl' + '?noCache=' + Math.random().toString(), method: 'GET', headers: { 'Access-Control-Allow-Origin': '*'}, body: '' }} />

Work's for me when i added method: 'GET', to source params

hichemBAALI avatar Jun 21 '21 10:06 hichemBAALI