Skip to content

Unable to get access from S3 #39

Open
@Franco8888

Description

@Franco8888

I take an URL from s3 and add it to the picker's _imageSrc attribute, but I am getting the following error:
has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

If I add the image to an img tag then it works and if I take a random image form the internet as the picker's _imageSrc then it works. But the documentation doesn't state how it get's access to the image, i.e. post, put, etc.?

Here are my S3 settings:

Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::********s"
            },
            "Action": [
                "s3:ListBucket",
                "s3:Get*",
                "s3:Put*",
                "s3:*"
            ],
            "Resource": "arn:aws:s3:::******"
        },
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::******/*"
        }
    ]
}

CORS settings:

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "DELETE",
            "HEAD",
            "GET"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [
            "Access-Control-Allow-Origin"
        ]
    }
]

Picker's code:

<ngp-image-picker
            ($imageChanged)="onImageChanged($event, i)"
            [_config]="config"
            [_imageSrc]="picker.imageSource"
            ></ngp-image-picker>

The picker.imageSource is the s3 URL
e.g.
https://ecomzabucket.s3.af-south-1.amazonaws.com/Onyx-Max-5000-Puff-Disposable-Rechargeable-img-main

What should be adjusted to the settings of s3 so that the picker gets access to the image/resource?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions