FastApi python aws s3 can't view image from url

Viewed 19

My image is uploading aws s3 bucket but can't view any image from url. Through I pass ExtraArgs={"ACL":"public-read"} but not understanding why it's not available publicly. here is my code:

@app.post("/post_ads")
async def create_upload_files(title: str = Form(),body: str = Form(), db: Session = Depends(get_db), files: list[UploadFile] = File(description="Multiple files as UploadFile")):
for file in files:
        if len(main_image_list) <= 5: 
                im = Image.open(file.file)
                im = im.convert("RGB")
                im_io = BytesIO()
                im = im.save(im_io, 'JPEG', quality=50)  
                s3 = boto3.resource(
                                's3',
                                aws_access_key_id =   aws_access_key_id,
                                aws_secret_access_key = aws_secret_access_key
                            )
                bucket = s3.Bucket(aws_bucket_name)
                im_io.seek(0) 
                bucket.upload_fileobj(im_io,file.filename,ExtraArgs={"ACL":"public-read"})
   

see the screenshot. When I am trying to view image from url I am getting this: enter image description here

0 Answers
Related