简体   繁体   English

Amazon S3文件上传:抛出403

[英]Amazon S3 File Upload: throwing up 403

I've been trying to implement a multipart file upload functionality where I'm using AjaxFileUpload to achieve this. 我一直在尝试实现多部分文件上传功能,其中我正在使用AjaxFileUpload来实现此目的。

Here's the use-case of my requirement: 这是我的需求的用例:

  1. Hit server-A to fetch up a presigned URL, which is valid for 15 minutes. 点击服务器A以获取一个预签名的URL,该URL的有效期为15分钟。
  2. The presigned URL is basically the path where I am trying to upload the multipart file to. 预先签名的URL基本上是我尝试将多部分文件上传到的路径。 That path is of Amazon S3 server. 该路径是Amazon S3服务器的路径。

The problem is, I'm getting a 403 here, on second step. 问题是,我在第二步得到403。

I've checked the calls on my part, they are going fine and according to the backend, they should be working good as well. 我已经检查了部分呼叫,它们运行良好,并且根据后端,它们也应该工作良好。

Here's my file-upload code block: 这是我的文件上传代码块:

$.ajaxFileUpload({
    url : data.preSignedUploadUrl,
    secureuri : true,
    fileElementId : 'uploadFile',
    dataType : 'json',
    contentType: "application/xml",
    success : function(data, status) {
        if(data.successful == true){
            self.sendUploadAcknowledgement(fileName);
        }else{
            $('#errorMessage').html(data.errors[0].description);
        }
    },
    error: function(err){
        console.error("Error in uploading file to S3!");
        console.log(err);
    }
});

Please note, the API calls are well-authorized and are wrapped up in their respective auth clusters. 请注意,API调用已得到充分授权,并包装在各自的身份验证群集中。

On the basis of various solutions found over the internet, I saw that I need to change my content-type in the request. 根据在Internet上找到的各种解决方案,我看到我需要更改请求中的内容类型。 I tried putting "application/xml", "application/json" in contentType key, even tried omitting it completely. 我尝试将“ application / xml”,“ application / json”放入contentType键中,甚至尝试完全省略它。

I want to know what am I doing wrong here on frontend, or is it just the fault of the backend? 我想知道前端在这里做错了什么,还是后端的错?

UPDATE: Well, the problem was there in the backend. 更新:嗯,问题出在后端。 The backend guy had messed up the permissions. 后端家伙搞砸了权限。 Now that he has fixed his part, everything is working as expected. 现在他已经固定了自己的角色,一切都按预期进行。 So, in short, to answer my question, it wasn't any fault on the frontend part, just that the backend had issues. 简而言之,要回答我的问题,前端部分没有任何问题,只是后端有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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