I am having an issue with uploading assets to S3 from Craft. So far I have taken the following steps:
- 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>" ] } ] }
- 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.
- 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.