我正在使用Django Uplodify S3,但我遇到了让它工作的问题。文件开始上传(显示进度),然后它们要么无限期地暂停,要么导致'Http Error‘。
我的python代码与给出的示例代码几乎相同。我在我的本地机器和dev服务器上运行它。
我一直收到HTTP错误400,Amazon报告POST请求中有我没有在策略中指定的额外字段。
在查看了mouad提供的链接后,我对策略进行了一些更改,以尝试包含所有我应该包含的文件,但我不确定是否正确声明了它们,因为Django Uploadfiy模块的文档有点不清楚。这就是我所拥有的:
@render
def upload_example(request, object_id):
options = {"onError":"function (a,b,c,d) {alert('Error: '+d.type+' Info: '+d.info)} "}
key_pattern = 'example-%s/${filename}' % object_id
post_data={
'key': key_pattern,
'success_action_status': "201",
"starts-with": object_id
}
#
# S3 uses conditions to validate the upload data. DUS3 automatically constructs
# and includes conditions for most of the elements that will be sent to S3, but you
# need to pass in conditions for:
# - 'key', whose value changes at upload time. Note that the condition's value
# must correspond to the key pattern set above.
# - any extra elements set at upload time
#
# See the DUS3 README for more information on the conditions mapping:
# https://github.com/sbc/django-uploadify-s3
#
conditions={
'key': { 'op': 'starts-with',
'value': ["$Filename", "$folder", "$key", "$Filedata", "$starts-with", "$Upload"], }
}
uploadify_options = uploadify_s3.UploadifyS3(
uploadify_options = options,
post_data=post_data,
conditions=conditions
).get_options_json()
return ['s3.html', {"opt": uploadify_options}]我最关心的部分是'key', whose value changes at upload time. Note that the condition's value。我不确定应该如何声明key的值。文档根本不是很清楚。
然后是来自亚马逊的错误日志:
7654158c29cb89182a7a8836253c91d61945e514e4a738ee1f502eda245f71e0 joshhunttest [08/Jun/2011:05:24:34 +0000] 137.166.55.199 - 8212E79B67E4469F REST.GET.OBJECT crossdomain.xml "GET /crossdomain.xml HTTP/1.1" 200 - 215 215 199 198 "http://localhost:8000/static/uploadify/uploadify.swf" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.10 Safari/535.1" -
7654158c29cb89182a7a8836253c91d61945e514e4a738ee1f502eda245f71e0 joshhunttest [08/Jun/2011:05:24:35 +0000] 137.166.55.199 - FDA8CED6EF7C3A19 REST.POST.BUCKET "POST / HTTP/1.1" 400 MaxPostPreDataLengthExceeded 360 - 1010 - "-" "Adobe Flash Player 10" -发布于 2011-06-11 16:20:30
这可能不太可能,但是您是否尝试过将字段从file_upload重命名为file
发布于 2011-06-17 04:17:27
我认为您的上传需要从'filedata‘更改为'file’。
请看这里的示例代码:http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1092&categoryID=47
https://stackoverflow.com/questions/6274484
复制相似问题