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.

質問済み 5年前5247ビュー
2回答
0
承認された回答

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

回答済み 5年前
0

Thank you very much! It worked!

回答済み 5年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ