Upload files to amazon s3 from wordpress

2019-08-01 05:44发布

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

2条回答
成全新的幸福
2楼-- · 2019-08-01 06:08
  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.

查看更多
女痞
3楼-- · 2019-08-01 06:11

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": "*"
    }
  ]
}
查看更多
登录 后发表回答