Receiving HTTP ERROR with Django Uploadify S3
I am using Django Uplodify S3 and I am having issues getting it to work. Files start to upload (progress is shown), then they just either pause indefinitely or result in a 'Http Error'.
My python code is pretty much identical to the example code given. I am running this on my local machine with the dev server.
I keep getting HTTP error 400, Amazon is reporting that there are extra fields in the POST request that I have not specified in my policy.
After looking at the link mouad provided, I made some changes to my policy to try and include all the files I should be, but I am not sure if I have declared them properly as the documentation for the Django Uploadfiy module is a bit unclear. Here's what I have:
@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_jso开发者_StackOverflow中文版n()
return ['s3.html', {"opt": uploadify_options}]
The part I am most concerned about is 'key', whose value changes at upload time. Note that the condition's value
. I am not sure how I should be declaring the value of key
. The documentation is not very clear at all.
And then here is the error log from Amazon:
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" -
This might be a long shot, but have you tried renaming the field from file_upload
to file
?
I believe your upload needs to be changed from 'filedata' to be named 'file'.
Take a look here for sample code: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1092&categoryID=47
精彩评论