简体   繁体   中英

django-uploadify-s3 and HTTP 403 Error

I'm using django-uploadify-s3. It worked great until I put:

'fileExt': r'*.sql'

in the uploadify_options.

My problem (I think) is the conditions field. I think I need to put the file extension exclusion into my conditions field as well. But I can't figure out how to do so. At the moment with the view shown below I get a 403 error.

The view in which the uploadify form is shown, looks like this:

@login_required
def upload_dump(req):
options = {'onComplete': 'uploadifyOnComplete',
           'onError': 'uploadifyOnError',
           'fileDesc': r'PostgreSQL dump files (*.sql)',
           'fileExt': r'*.sql',
           'buttonText': r'Select SQL dump',
          } 
key_pattern = 'tc-%s/${filename}' % req.user.username
post_data={'key': key_pattern, 'success_action_status': "201"}
conditions={'key': {'op': 'starts-with', 'value': 'tc-%s/' % req.user.username},
            'fileExt': {'op': 'starts-with', 'value': r'sql'},
           }
uploadify_options = uploadify_s3.UploadifyS3(uploadify_options=options, 
                                           post_data=post_data,
                                           conditions=conditions).get_options_json()
return direct_to_template(req, 'users/upload_dump.html',    
                          'uploadify_options':uploadify_options}

I don't think your conditions variable is supposed to contain a 'fileExt' key-value pair. fileExt is a property of Uploadify, not Amazon S3 POST process, and options is how you configure the Uploadify widget.

The conditions variable is what gets serialized into the policy file that gets sent to Amazon S3 and explains the rules file uploads must follow.

If you remove 'fileExt' from conditions, that should fix it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM