Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
Unable to Display Image from S3 Using Signed URL : React/Amplify

I am attempting to retrieve and display images from S3 using a signed URL. I can log the Signed URL to the console, click it, and it will download the image locally. The downloaded image is not corrupted in any way.

: Component Hierarchy

App
- Maps
-- Map

The App component manages filtering of maps, the filtered maps state is then passed to the Maps component which dynamically renders Map components.

export default function Maps({ maps }) {
    return (
        <Carousel
            autoPlay={false}
            PrevIcon={<ArrowCircleLeftIcon fontSize='large' />}
            NextIcon={<ArrowCircleRightIcon fontSize='large' />}
        >
            {maps.map((map, i) => (
                <Map key={i} map={map} />
            ))}
        </Carousel>
    )
}

My Map component holds state containing the Maps Image URL, and a useEffect hook which calls a getImg function.

export default function Map({ map }) {
    const [mapImg, setMapImg] = useState(null)

    useEffect(() => {
        if (map.uri) {
            getImg(map.uri).then((res) => {
                console.log(res)
                setMapImg(res)
            })
        }
    }, [map.uri])

return (
    <CardMedia
        component='img'
        alt='random nature'
        height='550'
        image={mapImg}
    />
)

Finally, the getImg function.

export const getImg = (uri) => {
    const uriToS3Path = (uri) => {
        let path = uri.substring(0, 6)
        const file = uri.substring(6) + '.TIF'
        path = path.split('').join('/') + '/'
        return path + file
    }

    const filePath = uriToS3Path(uri)
    return Storage.get(filePath, { contentType: 'image/tiff' })
}

Don't be confused by map.uri, basically this property determines the key for the S3 object, hence the uriToS3Path function as above. I don't receive any debug errors, I can retrieve the link but the image does not display. Is it due to some asynchronous activity or should the entire approach to fetching be altered?

Many Thanks.

Update: Inspecting the Application tab within the developer console. You can see that the S3 Image is listed (92.TIF), but the preview is broken.

Application Tab - Developer Console

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!