Fine Uploader S3 - 在完成回调时返回上传的URL

时间:2014-05-15 20:48:38

标签: amazon-s3 fine-uploader

如何使用精细上传程序在我的亚马逊s3水桶上获取上传图像的完整图像网址?

我的javascript代码是:

jQuery(document).ready(function () {
    jQuery("#fine-uploader").fineUploaderS3({
        debug: true,
        request: {
            endpoint: 'bucket.s3.amazonaws.com',
            accessKey: 'xxxxxxxx'
        },
        signature: {
            endpoint: 'end.php '
        },
        uploadSuccess: {
            endpoint: 'success.php '
        },
        iframeSupport: {
            localBlankPagePath: 'success.html '
        },
        retry: {
            enableAuto: true
        },
        validation: {
            allowedExtensions: ['
                jpeg ', '
                jpg ', '
                png '],
            sizeLimit: 1048576
        }
    }).on('
    complete ', function (event, id, name, response) {
        console.log(response.tempLink);
   });
});

更新

在s3演示之后,我正在使用response.tempLink并尝试将其记录到控制台,然后我将在稍后使用它。上传始终正常,但我的控制台每次都返回一个未定义的响应。

从找到这个q& a:having trouble displaying an image uploaded to Amazon s3 by fine-uploader

似乎我的IAM用户/政策设置以及$serverPublicKey$serverPrivateKey可能是原因?我的设置是:

我的end.php文件的此文件的精确副本: https://github.com/Widen/fine-uploader-server/blob/master/php/s3/s3demo-cors.php

进行以下更改:

// changed to match the secret access key for the FIRST IAM user as discussed in the docs
$clientPrivateKey = 'user_secret_key...';

// bucket name
$expectedBucketName = "my.bucket.name";

// changed to match the access and secret of the SECOND IAM 'server' user
$serverPublicKey = 'server_user_access_key...';
$serverPrivateKey = 'server user secret key...';

// updated to my website
function handlePreflightedRequest() {
    header('Access-Control-Allow-Origin: http://www.mywebsite.com');
}

在我的亚马逊IAM控制台中,我有第二台IAM'服务器'用户设置为:

组: GRP-服务器

组策略:( GetObject是正确的操作吗?)

{
    "Version":"2012-10-17",
    "Statement":[{
    "Effect":"Allow",
     "Action":"s3:GetObject",
     "Resource":"arn:aws:s3:::my.bucket.name/*"
    }]
}

或者我已尝试过以下操作,只需检查

即可获得完整的管理员权限
{
    "Version":"2012-10-17",
    "Statement":[{
    "Effect":"Allow",
     "Resource":"*"
    }]
}

用户: 用户服务器 添加到grp-server(继承组策略)

user-server access key becomes $serverPublicKey in end.php
user-server secret key becomes $serverPrivateKey in end.php

我错过了什么?

1 个答案:

答案 0 :(得分:0)

uploadSuccess.endpoint返回pre-signed URL,然后在onComplete处理程序中处理。请注意,预签名的URL只能在服务器端生成。请参阅this PHP server for details