1

I am having an issue with uploading assets to S3 from Craft. So far I have taken the following steps:

  1. Create permission policy and attached to group containing craft user:
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "s3:ListAllMyBuckets"
                ],
                "Resource": "arn:aws:s3:::"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "s3:GetBucketLocation",
                    "s3:ListBucket",
                    "s3:PutObject",
                    "s3:GetObject",
                    "s3:DeleteObject",
                    "s3:GetObjectAcl",
                    "s3:PutObjectAcl"
                ],
                "Resource": [
                    "arn:aws:s3:::<bucket_name>/*"
                ]
            },
            {
                "Effect": "Allow",
                "Action": [
                    "s3:GetBucketLocation",
                    "s3:ListBucket"
                ],
                "Resource": [
                    "arn:aws:s3:::<bucket_name>"
                ]
            }
        ] }
    
  2. Create new asset source with type of Amazon S3 and input access and secret key for craft user. This allows me to select the available bucket.
  3. Save the asset source and go to the asset section to upload a file to S3. At this point the status bar fills up and the upload hangs indefinitely.

Other notes:

  • These are very small images (<100KB)
  • I am able to bring images into Craft if I upload them directly to S3 and then update asset indexes in the setting.
  • I also noticed that the error logs print out the message:

    exception 'S3Exception' with message 'S3::getObjectInfo([bucket_name], [file_name]): [52] Empty reply from server' in /Users/[user]/Sites/[project]/craft/app/lib/S3.php:777

  • I have also tried using the more broad 'AmazonS3FullAccess' policy with the same results.

EDIT: In continuing to explorer this issue I have found that a call is being made from the S3AssetSourceType file in the insertFileInFolder function to the S3 class getObjectInfo function. It seems like this error is occurring because the code is trying to fetch information from amazon on an object that does not yet exist because this call occurs prior to the put object call. I have yet to understand why the getObjectInfo is called within the insertFileInFolder call before a put object request is made to S3.

EDIT 2: After more troubleshooting and testing this on a remote server it looks like the issue has to do with our company firewall not allowing receipt of the response object from the S3 request. We had no issues uploading assets to S3 from the same codebase on a remote server and are now looking into a work-around with the firewall.

  • Do local assets work OK? – RitterKnight Feb 24 '16 at 23:23
  • Yes. I initially started with a local folder and all the images uploaded fine through craft. I then updated that local assets source to use S3 and saw this error. After that I deleted the original assets source and created a new S3 source from scratch with a new S3 user and still received the same error. – tplassman Feb 25 '16 at 14:07
  • It's fetching the file info to make sure that such a file does not exist already. Is your server time set correctly? – Andris Sevcenko Mar 4 '16 at 14:42
  • That makes sense. Thanks for the clarification. I checked the timezone and indeed, the timezone in Craft was set to UTC while the php timezone was set to America/New_York. I updated the timezone in Craft but still get the same error when trying to upload. Is there anything else I should do after changing the timezone and before trying to upload assets? – tplassman Mar 4 '16 at 15:35
  • Did you find a way around this? Having the same problem now. – peirix Nov 24 '16 at 8:24
1

Per the original poster's 2nd edit, the issue had to do with their company firewall blocking the request to S3.

After more troubleshooting and testing this on a remote server it looks like the issue has to do with our company firewall not allowing receipt of the response object from the S3 request. We had no issues uploading assets to S3 from the same codebase on a remote server and are now looking into a work-around with the firewall.

|improve this answer|||||
  • Looks like this is a problem that occurs every now and then, and we just ran into it now. So would it be possible to have a troubleshooting section for this in the Craft documentation? – peirix Nov 24 '16 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.