ColdFusion CFUPLOAD to S3 Permissions Issue - Unable to view image

Using ColdFusion, I successfully upload the image to the Amazon S3 bucket and folder. I can confirm that the file is there. This is the code:

<cfparam name="attributes.bSubmit" default="" />

<cfif Trim(attributes.bSubmit) NEQ "">
    <cfset local.filePath = "#application.Config.cdnDirAbs#/public/" />
    <cffile action="upload" filefield="tFile" destination="#local.filePath#" nameconflict="makeunique" charset="utf-8" />
    <cfoutput>DONE UPLOAD</cfoutput>
    <cfoutput>
        <img src="#application.Config.staticContentDirAbs#/public/#cffile.clientfile#">
    </cfoutput>
</cfif>

<form method="post" enctype="multipart/form-data">
    Select a File 
    <input type="file" name="tFile" />
    <input type="submit" value="Submit" name="bSubmit" />
</form>

As you can see, I upload the image file to the "public" folder of my Amazon S3 bucket.

In this "public" folder there is a "READ" permission for "ALL USERS".

However, when an image is uploaded, it does not inherit this resolution.

Therefore, when I try to display an image, it is not displayed. When I view it in the browser at its URL, it displays xml with the message "AccessDenied".

/ READ URL-, .

READ- ( "public" ). , , / ?

!

. S3, ALMOST. , , " ", .

, URL- , "ACCESSDENIED" . . ?

{
  "Version": "2008-10-17",
  "Id": "Policy1380565312345",
  "Statement": [
    {
      "Sid": "Stmt1380565312345",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::mysitedev/*",
      "Condition": {
        "StringLike": {
          "aws:Referer": "*"
        }
      }
    }
  ]
}
+4
1

S3 Bucket, .

, , .

- Condition, Bucket , . , , -, , .

, , :

{
    "Version": "2008-10-17",
    "Id": "Policy1380565312345",
    "Statement": [{
        "Sid": "Stmt1380565312345",
        "Effect": "Allow",
        "Principal": {
            "AWS": "*"
        },
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::mysitedev/*"
    }]
}

Bucket . !

+2

Source: https://habr.com/ru/post/1692315/


All Articles