Django-uploadify-s3 and HTTP 403 Error

I am using django-uploadify-s3. It worked fine until I set:

'fileExt': r'*.sql' 

in the uploadify_options file.

My problem (I think) is the condition field. I think that I also need to exclude the file extension in the field of my conditions. But I can’t figure out how to do this. At the moment, with the image below, I am getting 403 error.

The view in which the upload form is shown is as follows:

 @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} 
+4
source share
1 answer

I do not think that your condition variable should contain a key-value pair 'fileExt'. fileExt is a Uploadify property, not an Amazon S3 POST, and the parameters are the settings of the Uploadify widget.

A condition variable is what gets serialized into a policy file, which is sent to Amazon S3, and explains how file files should be loaded.

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

0
source

Source: https://habr.com/ru/post/1340692/


All Articles