WordPress.org

Forums

Amazon S3 and Cloudfront
get_secure_attachment_url not working (1 post)

  1. barakdanin
    Member
    Posted 1 year ago #

    I used this code:
    $id=<<post id>>;
    global $as3cf;
    $url = $as3cf->get_secure_attachment_url($id);

    And got this url:
    http://floralegacy.s3.amazonaws.com/files2/146/14671.pdf?AWSAccessKeyId=AKIAJBABBTNK7O4RV6WA&Expires=1397401696&Signature=DH2NuM1r%2B4casctJY4kxyvzi4D8%3D

    But when I try to use it (via code, fopen with the URL created), I get this message:
    Warning: fopen(http://floralegacy.s3.amazonaws.com/files2/146/14671.pdf?AWSAccessKeyId=AKIAJBABBTNK7O4RV6WA&Expires=1397401696&Signature=DH2NuM1r%2B4casctJY4kxyvzi4D8%3D) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home (...)

    And when I open the generated URL in the browser:
    <Error>
    AccessDenied
    <Message>Access Denied</Message>
    <RequestId>EAA7FF577BA73AF5</RequestId>
    <HostId>
    SvRCVP8L+XBj54m3JohqBO1nJypU46DM7sSxc7om4tcIhmOVmkJkJalRdFRtAz50
    </HostId>
    </Error>

    My bucket has a policy that prevents hotlinking, but to my understanding this should not affect a secure URL, and any case this code is being executed on a server that's permitted in the policy (both flora.org.il and localhost:8080):
    {
    "Version": "2008-10-17",
    "Id": "HTTPreferrerpolicy",
    "Statement": [
    {
    "Sid": "1",
    "Effect": "Deny",
    "Principal": {
    "AWS": "*"
    },
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::floralegacy/*",
    "Condition": {
    "StringNotLike": {
    "aws:Referer": [
    "http://blog.flora.org.il/*",
    "http://flora.org.il/*",
    "http://localhost:8080/*"
    ]
    }
    }
    }
    ]
    }

    Any help would be much appreciated.

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Amazon S3 and Cloudfront
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.