AWS SignatureDoesNotMatch重试失败的上传

时间:2017-03-30 12:14:49

标签: amazon-s3

使用FineUploader并在我的页面上尝试手动重试先前失败的上传请求(几个小时后)。

我的服务器的签名请求来自"标题"即发出多部分信号。我进行计算并仅发送签名(此处没有策略文件),主要是在Python实现之后。

但AWS拒绝使用SignatureDoesNotMatch的请求。

AWS端是否有时间限制,必须在其中重试请求?下面是multipart签名请求的JS实现。任何有用的帮助。

function s3CredentialsMP(config, headers) {
  console.log("Signing the below str");
  console.log(headers);
  splits = headers.split("POST");
  creq = splits[1];
  bHdr = splits[0];
  canonical_req = "POST" + creq;
  algo = bHdr[0];
  amz_date = bHdr[1];
  cred_scope = bHdr[2];

  cred_parts = cred_scope.split('/');
  date_stamp = cred_parts[0];
  regionName = cred_parts[1];
  serviceName = cred_parts[2];

  signingKey = s3UploadSigningKey(config, date_stamp, regionName, serviceName);

  CryptoJS = require("crypto-js");
  hexDigestCreq = CryptoJS.SHA256(creq).toString(CryptoJS.enc.Hex);

  string_to_sign = algo + "\n" + amz_date + "\n" + cred_scope +
     "\n" + hexDigestCreq;

  sigVal = hmac(config.secretKey, string_to_sign).toString('hex');

  return {
    signature: sigVal
  }
}


Params IN multi-part sig request :
AWS4-HMAC-SHA256
20170330T120109Z
20170330/us-west-2/s3/aws4_request
POST
/1143%20Delivered.las
uploads=
host:lasfupload.s3-us-west-2.amazonaws.com
x-amz-acl:private
x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date:20170330T120109Z
x-amz-meta-qqfilename:1143%20Delivered.las

host;x-amz-acl;x-amz-content-sha256;x-amz-date;x-amz-meta-qqfilename
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855


Signature :  2231a6dd8dc0917def780bfc114ed10e459f8f748195c2d05c217684461dfec1

0 个答案:

没有答案