简体   繁体   中英

Upload files to amazon s3 from wordpress

I've searched and researched but I cannot seem to find any solution. I really need to integrate an amazon s3 uploader from within the wordpress page/post edit screen. There are a ton of plugin that upload everything to s3 but not even one that upload only selected files.

The ideal scenario would be adding an extra tab to the wp media gallery that uploads directly to s3...unfortunetely I cannot find a way to make it work.

I followed various tutorials and I've managed to upload files to s3 via php, but I cannot do it within WP.

It is that even possible? Could anyone help me or point me in the right direction?

I thank you all in advance for any help or tips you could give me.

Regards, Antonio

When using this plugin, https://wordpress.org/plugins/amazon-s3-and-cloudfront/

This unrestrictive policy is suggested by the plugin.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "*"
    }
  ]
}
  1. First go here and read this -

http://blogs.aws.amazon.com/security/post/Tx3VRSWZ6B3SHAV/Writing-IAM-Policies-How-to-grant-access-to-an-Amazon-S3-bucket

  1. Create your bucket, a user which will work with your Wordpress installation. Write policy for the user to access your S3 bucket as below, not the simple form AWS blog mentioned -
{
      "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": {}
        }
      ]
    }

Then go to Wordpress...

  1. Install this first https://github.com/deliciousbrains/wp-amazon-web-services

  2. Install http://wordpress.org/plugins/amazon-s3-and-cloudfront/ and setup wp-config.php.

Then you are ready to go. URLs should indicate if it is working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM