2017-12-13 12 views
1

아마존 s3 버킷에 pdf 파일을 업로드하고 싶습니다. 하지만 파일 경로가없는 파일 업로드를 받고있다ionic 3 앱에서 amazon s3 버킷으로 pdf 파일 업로드

귀하의 문제가이 코드로 자리 잡고
var filepath = ""; 
var that = this; 
this.fileChooser.open() 
    .then(uri => { 
    console.log(uri); 
    filepath = uri; 

    var fileName = 'File_' + this.global.gerUniqueString() + ".pdf"; 

    var AWSService = window.AWS; 
    AWSService.config.accessKeyId = this.global.accessKeyId; 
    AWSService.config.secretAccessKey = this.global.secretAccessKey; 
    AWSService.config.region = 'ap-south-1'; 
    var bucket = new AWSService.S3({ params: { Bucket: this.global.bucketName } }); 
    var body = 'data:application/pdf', base64, filepath; 
    var params = { Key: fileName, Body: body }; 
    bucket.upload(params, function (err, data) { 

     console.log(err, data); 

    }); 

    }) 
    .catch(e => console.log(e)); 

답변

0

: 나는 당신이 시도하고있는 무슨 확실하지 않다

var params = {Key: filename, ContentType: 'application/pdf', Body: filepath}; 

:

var body = 'data:application/pdf', base64, filepath; 
var params = { Key: fileName, Body: body }; 

변경에 base64으로 완료하십시오.