开发者

Amazon S3 Upload With Uploadify?

Can someone please have a look at this code i have been working non stop with this and really struggling to get it working, cant understand where i am going wrong.

I am using the amazon undesigned s3 class, and uploadify to create a direct upload.

http://www.uploadify.com

http://undesigned.org.za/2007/10/22/amazon-s3-php-class

Here is the policy it generates for me.

"AWSAccessKeyId": encodeURIComponent(encodeURIComponent("Amazon Key")), "key": encodeURIComponent(encodeURIComponent("${filename}")), "acl": encodeURIComponent(encodeURIComponent("private")), "policy": encodeURIComponent(encodeURIComponent("eyJleHBpcmF0aW9uIjoiMjAxMS0wMS0yOFQwMjowMTowNVoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJpc2RtdXNpYyJ9LHsiYWNsIjoicHJpdmF0ZSJ9LHsic3VjY2Vzc19hY3Rpb25fc3RhdHVzIjoiMjAxIn0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCIiXSxbInN0YXJ0cy13aXRoIiwiJGZvbGRlciIsIiJdLFsic3RhcnRzLXdpdGgiLCIkRmlsZW5hbWUiLCIiXSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDUyNDI4ODAwXV19")), "signature": encodeURIComponent(encodeURIComponent("/SY2fMBopByN90qU27EUFClT52c=")), "success_action_status": encodeURIComponent(encodeURIComponent("201")), "folder": encodeURIComponent(encodeU开发者_开发知识库RIComponent("")), "Filename": encodeURIComponent(encodeURIComponent("")) 

So that works grabbing everything i need here is my full code.

    <html>
<head>
<script type="text/javascript" src="up/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="up/swfobject.js"></script>
<script type="text/javascript" src="up/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#uploadify_div').uploadify({
'uploader': 'up/uploadify.swf',
'script' : '<a href="http://bucket.s3.amazonaws.com" target="_blank" rel="nofollow">http://bucket.s3.amazonaws.com</a>',
'scriptData' : {
<?php
$output = '';
foreach ($post_params as $p => $v) {
$output .= '"'.$p.'": encodeURIComponent(encodeURIComponent("'.$v.'")),'."\n";
}
echo substr($output, 0, -2);
?>
},
'fileDataName' : 'file',
'scriptAccess' : 'always',
'onError' : function(a, b, c, d) {
if (d.info == 201) {
var $queue = $('#queue').html('Processing, please wait...').show();
$.post(
'user/s3flphoto/f2507de7ea81f68b3eddcdfd876fd144',
{'fn': c.name},
function(data) {
$queue.hide();
}
);
} else {
page_message('Ughh, something wrong happened. Can you please try again?', 1);
}
},
'onComplete' : function(a, b, c, d, e) {
var $queue = $('#queue').html('Processing, please wait...').show();
$.post(
'user/s3flphoto/f2507de7ea81f68b3eddcdfd876fd144',
{'xml': d},
function(data) {
$queue.hide();
}
);
},
'folder' : '',
'auto' : true,
'multi' : false
});

});
</script>
</head>
<body>
<div id="uploadify_div"></div>
</body>
</html>

And here is a link to my example http://www.isimpledesign.co.uk/amazon_upload/

if i view source it seems to be populating everything correctly in script data adding all policy.

scriptData : {
"AWSAccessKeyId": encodeURIComponent(encodeURIComponent("amazon key")),
"key": encodeURIComponent(encodeURIComponent("${filename}")),
"acl": encodeURIComponent(encodeURIComponent("private")),
"policy": encodeURIComponent(encodeURIComponent("eyJleHBpcmF0aW9uIjoiMjAxMS0wMS0yOFQwOToxNTo1M1oiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJpc2RtdXNpYyJ9LHsiYWNsIjoicHJpdmF0ZSJ9LHsic3VjY2Vzc19hY3Rpb25fc3RhdHVzIjoiMjAxIn0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCIiXSxbInN0YXJ0cy13aXRoIiwiJGZvbGRlciIsIiJdLFsic3RhcnRzLXdpdGgiLCIkRmlsZW5hbWUiLCIiXSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDUyNDI4ODAwXV19")),
"signature": encodeURIComponent(encodeURIComponent("8db8ZgvfMKe5uvI/fwzNXxKCCZA=")),
"success_action_status": encodeURIComponent(encodeURIComponent("201")),
"folder": encodeURIComponent(encodeURIComponent("")),
"Filename": encodeURIComponent(encodeURIComponent("")),
},

I have hit a brick wall with this now would really appreciate some help people.

Thanks

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜