我正在使用Django Uplodify S3并且在使用它时遇到问题。文件开始上传(显示进度),然后它们要么无限期暂停,要么导致“Http错误”。在
我的python代码与给定的示例代码几乎完全相同。我在我的本地机器上运行这个开发服务器。在
我一直收到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
的值。文件一点也不清楚。在
下面是来自Amazon的错误日志:
^{pr2}$
这可能是一个很长的尝试,但是您是否尝试过将字段从
file_upload
重命名为file
?在我相信你的上传需要从“filedata”改为“file”。在
在这里查看示例代码: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1092&categoryID=47
相关问题 更多 >
编程相关推荐