Diplay pictures stored in s3 to web page

0

I am builiding a web app with flask that allows user to update pictures to it. The pictures then get displayed on the web page.
I was able to connect flask with S3 to upload pictures to my bucket, but I can not display them on my page.

Is it possible to use something like this in my html to return the pictures?
<img src="https://oldports-static-images.s3.us-east-2.amazonaws.com/fun_E4173.jpg " width="200px" height="200px">
why wouldn't this work?

My bucket has public read permissions (I think), I would expect that if I opened the link I would see the pictures? I get an error message.
https://oldports-static-images.s3.us-east-2.amazonaws.com/fun_E4173.jpg

I appreciate any help I can be given, I am new to development and this part is overwhelming to me.

demandé il y a 5 ans5247 vues
2 réponses
0
Réponse acceptée

Hi,
Most likely you just need to set the Bucket Policy to public so that anyone can view the images (and they will be available for use to embed in your web page).

  1. Go to Services - Amazon S3
  2. Click on the link to your bucket "oldports-static-images"
  3. Click on Permissions. Make sure you have "Block public access" set to Off. If no, hit the Edit Button and set to Off.
  4. If "Bucket Policy" is NOT marked "Public", then click on Bucket Policy (on Permissions tab).
  5. Enter the Following Bucket Policy:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::oldports-static-images/*"
        }
    ]
}
  1. Hit Save
  2. You should now see the Bucket Policy and Permissions both tagged with "Public"
    You should now be able to upload any files to this bucket and reference them with your URL.

Hope this helps!
-randy

répondu il y a 5 ans
0

Thank you very much! It worked!

répondu il y a 5 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions