使用Uploadify以直接张贴到Amazon S3

编程入门 行业动态 更新时间:2024-10-15 14:14:47
本文介绍了使用Uploadify以直接张贴到Amazon S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

谁能告诉我如何使用 Uploadify 直接上传到亚马逊的S3?

Can anyone tell me how to use Uploadify to upload directly to Amazon S3?

我的code是如下:

$('#fileInput').uploadify({ 'fileDataName' : 'file', 'uploader' : 'uploadify.swf', 'script' : 'BUCKET-NAME-GOES-HERE.s3.amazonaws/', 'cancelImg' : 'cancel.png', 'method' : 'post', 'auto' : true, 'onError': function (a, b, c, d) { alert('error '+d.type+": "+d.info + ' name: ' + c.name + ' size: ' + c.size); }, 'scriptData' : { 'AWSAccessKeyId': "KEY-GOES-HERE", 'key': "${filename}", 'acl': "public-read", 'policy': "POLICY-STRING-GOES-HERE", 'signature': "SIGNATURE-GOES-HERE", 'success_action_status': '200' } });

我的(unen codeD)政策字符串看起来是这样的:

My (unencoded) policy string looks like this:

{ "expiration": "2100-12-01T12:00:00.000Z", "conditions": [ {"acl": "public-read"}, {"bucket": "BUCKET-NAME-GOES-HERE"}, {"success_action_status" : 200}, ["starts-with", "$filename", ""], ["starts-with", "$folder", ""], ["starts-with", "$key", ""], ["content-length-range", 1, 209715200] ] }

使用上述code其实可以让我选择一个文件,它会出现上传(的地方),但没有出现在我的S3存储桶,并没有错误返回给JS控制台。

Using the above code actually allows me to select a file, which it then appears to upload (somewhere), but nothing shows up in my S3 bucket and no errors are returned to the JS console.

使用普通的HTML表单张贴文件到S3存储工作正常。

Using a regular HTML form to post a file to the S3 bucket works fine.

任何意见?

推荐答案

在此的发的uploadify论坛:

From this thread the uploadify forum:

<html> <head> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="swfobject.js"></script> <script type="text/javascript" src="jquery.uploadify.v2.1.0.js"></script> <link rel="stylesheet" href="uploadify.css" type="text/css" media="screen" /> </head> <body> <form> <input id="fileInput" name="fileInput" type="file" /> </form> <script type="text/javascript">// <![CDATA[ $(document).ready(function() { $('#fileInput').uploadify({ 'fileDataName' : 'file', 'uploader' : 'uploadify.swf', 'script' : 'UPLOADBUCKET/', 'cancelImg' : 'cancel.png', 'auto' : true, 'onError' : function(errorObj, q, f, err) { console.log(err); }, 'scriptData' : { AWSAccessKeyId: "ACCESS_KEY", key: "foo/${filename}", acl: "public-read", policy: "POLICY STRING" signature: "SIGNATURE, success_action_status: '200' } }); }); // ]]></script> </body> </html>

的碱为策略字符串如下:

The base for the policy string is as follows:

{ "expiration": "2100-12-01T12:00:00.000Z", "conditions": [ {"acl": "public-read" }, {"bucket": "UPLOADBUCKET" }, {"success_action_status" : '200'}, ["starts-with", "$filename", "" ], ["starts-with", "$folder", "" ], ["starts-with", "$key", "foo"], ["content-length-range", 1, 209715200] ] }

更多推荐

使用Uploadify以直接张贴到Amazon S3

本文发布于:2023-11-23 16:43:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622168.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:贴到   Uploadify   Amazon

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!