S3使用签名URL上传|禁止的Angular 8,403

时间:2019-07-14 21:07:13

标签: javascript angular amazon-s3

我能够成功地将对象上传到S3存储桶!

var req = require('request');
var fs = require('fs');
var AWS = require('aws-sdk');

AWS.config.update({
  accessKeyId: "",
  secretAccessKey: ""
});

var s3 = new AWS.S3();
var params = {Bucket: '', Key: 'excalibur4/items/Excel.jpg', Expires: 3000};
var url = s3.getSignedUrl('putObject', params);

fs.readFile('./Excel.xlsx', function(err, data){
  if(err){
    return console.log(err);
  }
  req({
    method: "PUT",
    url: url,
    body: data
  }, function(err, res, body){
    console.log(body);
  })
});

在Angular中应该如何转换?

我,只需要发送PUT请求到预先签名的URL!

let image: Buffer = respArr[0];
let url: string = respArr[1];
this.http.put(url, image).subscribe(console.log, console.error);

0 个答案:

没有答案