6

ngCordova FileTransfer 플러그인을 사용하여 AWS-S3에 사전 서명 된 URL을 사용하여 파일을 업로드하려고합니다.ngCordova FileTransfer AWS S3에 직접 업로드 WebKitFormBoundary 문제

나는 성공적으로 AWS-S3에 파일을 업로드 할 수 있어요하지만 파일의 내용은 이미지 파일을 열 수 없습니다 때문에되는

------WebKitFormBoundarylCFgJXqqECF1rJ2m Content-Disposition: form-data; name="file"; filename="75cae09191bd92a16c3ff05baeb88b9b.jpg" Content-Type: image/jpeg 이 포함되어 있습니다. 어떻게 파일에서이 헤더를 제거 할 수 있습니까? 폼 데이터 대신 바이너리 데이터를 넣으면 POSTMAN에서 테스트했지만 코드로 파일 전송에서이 작업을 수행 할 수있는 방법을 찾을 수 없다는 생각을 가지고 있습니다.

$cordovaFileTransfer.upload(s3SignedUrl, imagePathOnPhone, { 
           fileKey: "file", 
           fileName: localFileName, 
           httpMethod: "PUT", 
           mimeType: 'image/jpeg' 
          }) 
           .then(function (result) { 
            console.log(result); 

           }, function (error) { 
            console.log(error); 

           }, function (progress) { 
            console.log(progress); 

           }); 

내 버킷은 프랑크푸르트 지역 및 api v4에 있습니다. 그리고 서버에서 nodejs를 사용하고 있습니다.

+0

봅니다 "의 Content-Type"을 추가. – daserge

+0

예 : https://github.com/apache/cordova-plugin-file-transfer/blob/855def11c3c35df6f9de10ccca46e7336baa2506/tests/tests.js#L1273-1276 https://github.com/apache/cordova-plugin-file- transfer # example-with-upload-headers-and-progress-events-android-and-ios-only – daserge

+0

나는 행운을 시험해 보았습니다. –

답변

1

Content-Type 속성을 params 섹션에 추가 해보십시오. opts.headers"Content-Type": "image/jpeg"를 추가

$cordovaFileTransfer.upload(s3SignedUrl, imagePathOnPhone, { 
    fileKey: "file", 
    fileName: localFileName, 
    httpMethod: "PUT", 
    mimeType: 'image/jpeg', 
    params: { 
     "Content-Type": "image/jpeg" 
    } 
}) 
.then(function (result) { 
    console.log(result); 

}, function (error) { 
    console.log(error); 

}, function (progress) { 
    console.log(progress); 

}); 
+1

'params '대신'options'을 써야합니다. – daserge

+0

아니요, 생성자의 세 번째 값은 이미'options' 객체입니다. docs - upload (server, targetPath, options, ...) - http://ngcordova.com/docs/plugins/fileTransfer/ 또는 http://www.gajotres.net/using-cordova-에서의 사례를 참조하십시오. file-transfer-plugin-with-ionic-framework/ –

+1

@daan.desmedt이 같은 옵션에서 설정해야합니다 : 옵션 = { 헤더 : { '콘텐츠 유형': '이미지/JPG', }, httpMethod : chunkedMode 'PUT'거짓 을}; – Gandhi

0

봅니다 다중 비활성화 : 여러 부분을 비활성화 OPTS에 "이미지/JPEG"

$cordovaFileTransfer.upload(s3SignedUrl, imagePathOnPhone, { 
    fileKey: "file", 
    fileName: localFileName, 
    httpMethod: "PUT", 
    mimeType: 'image/jpeg', 
    headers: { 
     "Content-Type": "image/jpeg" 
    } 
}) 
.then(function (result) { 
    console.log(result); 
}, function (error) { 
    console.log(error); 
}, function (progress) { 
    console.log(progress); 
}); 
+0

나는 내일 그렇게하려고합니다. 내 결과를 알려줄거야. –

관련 문제