function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Priyanka Dhanorkar 22Priyanka Dhanorkar 22 

How can I show image in react native app from SF files

I have a react native app that is connected to my Salesforce org, using the connected app. I am able to show the text fields from the salesforce. But when I try to show a image url in the react native app, it does not load. The url is a public url of a image stored in the files in SF.

Any pointers will be really helpful.
Todd Halfpenny MCTodd Halfpenny MC

Yes, you can certainly do this, it might be a case of using the correct URL.

The first step I'd take here is to use the browser Developer Console (https://facebook.github.io/react-native/docs/debugging.html) to check the network requests to see if you can find out what response reason is given for the failure (e.g. 5XX server error). With this info you should be able to decide on why it's happening.

Priyanka Dhanorkar 22Priyanka Dhanorkar 22
Thanks Todd. 

The url is correct, since my teammates can access the image using the same url.

I have tried using the image url in Image tag as well, but no luck.

Any other help would be appreciated.
 
Todd Halfpenny MCTodd Halfpenny MC
OK, then I suggest you still try using the debug tools, as this still might give you information (maybe there's a CORS issue, or similar).
Priyanka Dhanorkar 22Priyanka Dhanorkar 22
Checked. No error in the debugger.

Have you ever been succesfull in showing an image from Salesoforce files into an react native app ?
Todd Halfpenny MCTodd Halfpenny MC

Not specifically in a React Native app, but in other native and hybrid apps we have.

Do you have access to a network log (similar to those seen in browser dev tools)? If so, perhaps there's an entry in there for the image.

Priyanka Dhanorkar 22Priyanka Dhanorkar 22
Hi Todd,

I could not see any issue in the dev tools.

Do you have any sample code or type of url that you can share which would show the image in any mobile app?

 
Priyanka Dhanorkar 22Priyanka Dhanorkar 22
This is what I see in the browser:
This is on the console.

This is on the network.
Todd Halfpenny MCTodd Halfpenny MC
Which URL are you trying to get the image from?
Priyanka Dhanorkar 22Priyanka Dhanorkar 22
Its a public url created for a image file in salesforce library.
Mayurkumar Maisuriya 14Mayurkumar Maisuriya 14
USe content download URL and not the public sharing URL. You can get the content Download URL from developer console, open ContentDistribustion object CTR + O, select Content Distribution, select Name and contentDownload URL, copy the ContentDownload URL for the Image asset that you want to render, and replace it to the public URL and you should be able to render it.