Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angular2想要上传到S3吗_Javascript_Angular_Amazon Web Services_Amazon S3 - Fatal编程技术网

Javascript Angular2想要上传到S3吗

Javascript Angular2想要上传到S3吗,javascript,angular,amazon-web-services,amazon-s3,Javascript,Angular,Amazon Web Services,Amazon S3,我想使用Angular 2进行多部分上传。 我编写了以下代码 import * as AWS from 'aws-sdk' @Component({ }) export class UploadComponent implements OnInit { progress: Array<any> = [] file: any constructor() { } ngOnInit() { } uploadfile(ev

我想使用Angular 2进行多部分上传。 我编写了以下代码

import * as AWS from 'aws-sdk'

@Component({

})
export class UploadComponent implements OnInit {

    progress: Array<any> = []
    file: any

    constructor() {

    }

    ngOnInit() {
    }

    uploadfile(event) {
        AWS.config.accessKeyId = '';
        AWS.config.secretAccessKey = '';
        AWS.config.region = ''
        let bucket = new AWS.S3({params: {Bucket: ''}});
        let params = {Key: this.file.name, Body: this.file, ContentType: this.file.type};
        bucket.upload(params, function (err, data) {
            console.log(err, data);
        });
    }

    fileEvent(event: any){
        let files = event.target.files
        let file = files[0]
        this.file = file
        console.log(this.file)
    }
}
请帮帮我。 我想听听你的建议


我试图获取信息,但无法得到正确答案。

检查此项您正在传递的对象似乎与预期传递给
上载
函数的对象不同。

让参数={Key:this.file.name,Body:this.file,ContentType:this.file.type}

//只要改变你的底线


var params={Bucket:'your Bucket name',Key:this.file.name,Body:this.file,ContentType:this.file.type}

你能查一下这个链接吗?因为你传递的对象似乎与传递给
upload
@sandyJoshi的对象不同,谢谢!!!我很傻。
 Argument of type '{ Key: any; Body: any; ContentType: any; }' is not assignable to parameter of type 'PutObjectRequest'.
  Property 'Bucket' is missing in type '{ Key: any; Body: any; ContentType: any; }'.)