Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

media not uploading to S3 bucket (plugin-cloud-storage)

default discord avatar
olivier_vdlast year
14

Dear all, I'm having trouble storing my media collection to an S3 bucket. I followed the instructions on the github repo.


these are my configurations:


- media collections:

https://github.com/oliviervd/cms-studios/blob/main/src/collections/Media.ts


- payload config :

https://github.com/oliviervd/cms-studios/blob/main/src/payload.config.ts
  • default discord avatar
    imcorfitzlast year

    Have you received any errors in the console that could be helpful?



    The IAM creds for your S3 bucket user - have they received sufficient permission to store data in your bucket? And have you made sure the correct bucket name is written in the permissions for the IAM role?

  • default discord avatar
    ngurajekalast year

    Also, you may need to put the region on the configuration as well.

  • default discord avatar
    olivier_vdlast year

    i've added a security policy to the user; still doesn't work though.


    what does the forcePathStyle do? Is it needed.



    {


    "Version": "2012-10-17",


    "Statement": [


    {


    "Sid": "VisualEditor0",


    "Effect": "Allow",


    "Action": "

    ",
    "Resource": [
    "arn:aws:s3:::{bucketname}",
    "arn:aws:s3::::{bucketname}/

    "


    ]


    }


    ]


    }



    in the console I'm getting a 404: not found error. I'm guessing my path isn't correct?

  • default discord avatar
    imcorfitzlast year
    forcePathStyle

    allows you to change how you fetch images again. Could be useful in cases where you have maybe fastly cdn or a custom image service proxy.



    Is the record created in Payload?

  • default discord avatar
    olivier_vdlast year

    yes it all works fine, it just doesn't store the file anywhere it seems.

  • default discord avatar
    imcorfitzlast year

    If you look in your S3 bucket through AWS management console - you don't see it there neither?

  • default discord avatar
    olivier_vdlast year

    no I checked



    do I need to use the user ARN as endpoint perhaps?

  • default discord avatar
    imcorfitzlast year

    I created a custom policy for an IAM user with following:


    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "VisualEditor0",
                "Effect": "Allow",
                "Action": [
                    "s3:PutObject",
                    "s3:GetObjectAcl",
                    "s3:GetObject",
                    "s3:PutBucketAcl",
                    "s3:ListBucket",
                    "s3:DeleteObject",
                    "s3:GetBucketAcl",
                    "s3:GetBucketLocation",
                    "s3:PutObjectAcl"
                ],
                "Resource": [
                    "arn:aws:s3:::<bucket-name>",
                    "arn:aws:s3:::<bucket-name>/*"
                ]
            }
        ]
    }


    May be a permissions issue



    Also note the asterisk here

    "arn:aws:s3:::<bucket-name>/*"

    Also looks like you have too many colons here

  • default discord avatar
    olivier_vdlast year

    S3://bucket-name/ would this be the endpoint?

  • default discord avatar
    imcorfitzlast year

    no

  • default discord avatar
    olivier_vdlast year

    or do i need it like this;

    https://s3.region-code.amazonaws.com/bucket-name/key-name

    ok i guess that's the issue 🙂

  • default discord avatar
    imcorfitzlast year

    S3_ACCESS_KEY_ID="IAM_ACCESSKEY"


    S3_SECRET_ACCESS_KEY="IAM_SECRET_ACCESS_KEY"


    S3_BUCKET="bucket-name"


    S3_REGION="eu-west-2"


    S3_ENDPOINT="

    https://s3.eu-west-2.amazonaws.com

    "

  • default discord avatar
    olivier_vdlast year

    Ok that resolved the issue. Everything works fine now! Thank you for your patience and help 🙂

  • default discord avatar
    imcorfitzlast year

    Most welcome bud

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.