【问题标题】:django-uploadify-s3 and HTTP 403 Errordjango-uploadify-s3 和 HTTP 403 错误
【发布时间】:2011-06-23 03:15:49
【问题描述】:

我正在使用 django-uploadify-s3。在我输入之前效果很好:

'fileExt': r'*.sql'

在uploadify_options中。

我的问题(我认为)是条件字段。我想我也需要将文件扩展名排除在我的条件字段中。但我不知道该怎么做。目前,如下图所示,出现 403 错误。

显示上传表单的视图如下所示:

@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}

【问题讨论】:

    标签: django amazon-s3 uploadify


    【解决方案1】:

    我认为您的条件变量不应该包含“fileExt”键值对。 fileExt 是 Uploadify 的属性,而不是 Amazon S3 POST 过程,而 options 是您配置 Uploadify 小部件的方式。

    条件变量是被序列化为发送到 Amazon S3 的策略文件的内容,并解释了文件上传必须遵循的规则。

    如果您从条件中删除“fileExt”,应该可以解决它。

    【讨论】:

      猜你喜欢
      • 2011-10-08
      • 1970-01-01
      • 2013-06-27
      • 2011-11-21
      • 1970-01-01
      • 2011-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多