WordPress.org

Ready to get started?Download WordPress

Forums

Amazon S3 and Cloudfront
Media are not uploading to Amazon S3 (11 posts)

  1. tomkerswill
    Member
    Posted 4 months ago #

    Hi

    I'm having an issue where my media is not uploaded to Amazon S3, even though the relevant boxes are ticked on the plugin. The problem seems similar to these two posts (see: this thread and this thread), although as instructed, I'm starting a new forum thread to track this.

    The URL of the media referenced in WordPress does not change either --- eg. it stays pointing to the local server. So it's behaving in the same way as you'd expect if the plugin was not working at all.

    The list of buckets is shown in the configuration page correctly, so I know that my access details are correct. Here is a screenshot of the page with my settings:

    Screenshot.

    Does anyone have any pointers on how this can be made to work?

    Thanks

    Tom

    https://wordpress.org/plugins/amazon-s3-and-cloudfront/

  2. TraciBunkers
    Member
    Posted 4 months ago #

    Tom, are you using cloudfront? Your screenshot shows you haven't put anything in the cloudfront settings.

    EDIT: But, if it's not uploading the files, then it won't change the URL, no matter if you are using cloudfront or not.

    EDIT #2: Also, did you look in your error log on your server? I can access mine form my cpanel. That might give you some info.

  3. TraciBunkers
    Member
    Posted 4 months ago #

    Tom, see this for info on a different plugin that seems to work. I installed it on my test site, and it worked.

  4. tomkerswill
    Member
    Posted 4 months ago #

    Hi TraciBunkers

    Re: CloudFront.. Yeah, not using it at the moment (might look at that later) - but you're right, I'm pretty sure it shouldn't matter, because the problem happens before I get to that point.

    Re: the error log... Ah, good idea! I don't know why I didn't do that before. The error is illuminating... And I wonder if this is happening because I'm using an EU bucket, rather than the default US one? The error I get is:

    Error uploading /srv/www/mywebsite/releases/20140306132721/wp-content/uploads/2014/03/Fullscreen_07_03_2014_16_29.png to S3: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint: "wordpress-media-mywebsite.com.s3.amazonaws.com"., referer: http://mywebsite.com/wordpress/wp-admin/media-new.php

    I guess to delve into this further, I should try and look at the code and see what endpoint it's trying to use... Or see whether it'll work with a US bucket...

    Tom

  5. tomkerswill
    Member
    Posted 4 months ago #

    Ah - yes, I've found the bug, I think.

    In the plugin, the S3 endpoint is hardcoded to:

    s3.amazonaws.com/BUCKETNAME

    ... which is "path-style syntax". The s3.amazonaws.com only works for US buckets. For other regions, it has to be changed - for example, for an EU bucket, it should be:

    http://s3-euwest-1.amazonaws.com/BUCKETNAME

    So I think that's why it's not working for my EU bucket.

    Another alternative (which works with all regions) is to change the syntax to use endpoints like this:

    wordpress-media-mywebsite.com.s3.amazonaws.com

    ... Which should work for all regions.

    I think that, in order to work with all regions, the code needs to be updated to work with domain-type URLs like the one above.

    Tom

  6. TraciBunkers
    Member
    Posted 4 months ago #

    Tom, look some some of the previous threads if you haven't already. I think I remember seeing some where people whose buckets weren't in the US were having problems. And I think the plugin author gave some workarounds--but I've looked at so much info, I don't really remember.

  7. tomkerswill
    Member
    Posted 4 months ago #

    Okay - I've got a workaround for making this work with regions outside the US.

    This can be fixed short-term by changing line 152 in wp-amazon-web-services-master/classes/amazon-web-services.php

    FROM:

    $args = array(
    'key' => $this->get_access_key_id(),
    'secret' => $this->get_secret_access_key()
    );

    TO:

    $args = array(
    'key' => $this->get_access_key_id(),
    'secret' => $this->get_secret_access_key(),
    'region' => 'eu-west-1'

    );

    ... Obviously this would need to be added to the admin interface instead of being hardcode here - but adding the region in does fix the problem, and images can now be uploaded to S3.

    I guess an enhancement is to either add a "region" dropdown to the admin interface, or - better still - detect the region from the chosen bucket automatically.

    Tom

  8. mandymck
    Member
    Posted 4 months ago #

    Thanks heaps for this workaround Tom, it has worked perfectly for me. For anyone needing a bucket in the Sydney region change 'region' => 'eu-west-1' to 'region' => 'ap-southeast-2'

    Mandy

  9. tomkerswill
    Member
    Posted 4 months ago #

    Hi Mandy,

    Ah - that's really good news!

    Tom

  10. ashpriom
    Member
    Posted 2 months ago #

    My problem was solved by editing my user policy to this -

    {
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "s3:ListBucket",
            "s3:GetBucketLocation",
            "s3:ListBucketMultipartUploads"
          ],
          "Resource": "arn:aws:s3:::celingest-cdn",
          "Condition": {}
        },
        {
          "Action": [
            "s3:AbortMultipartUpload",
            "s3:DeleteObject*",
            "s3:GetObject*",
            "s3:PutObject*"
          ],
          "Effect": "Allow",
          "Resource": [
            "arn:aws:s3:::celingest-cdn/*"
          ]
        },
        {
          "Effect": "Allow",
          "Action": "s3:ListAllMyBuckets",
          "Resource": "*",
          "Condition": {}
        }
      ]
    }

    http://pastebin.com/raw.php?i=ydiQLXGY
    http://blog.celingest.com/en/2013/07/19/tutorial-creating-cdn-wordpress-cloudfront-s3/

  11. niccol
    Member
    Posted 1 month ago #

    @tomkerswill

    Thank you. That saved some time working it out myself.

    And, yes, I agree that an admin dropdown would be ideal.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.