0

これは私がサーバーに画像を転送するのに使った機能です。 http urlで動作していたので、https urlで例外が発生しました。私は、コードバファイル転送プラグインがhttpとhttpsだけをサポートしているためだと思います。他のものがそれに依存しているので、httpsでこれを動作させる手助けができますか?HTTPSを使用したCordovaプラグインファイル転送

public uploadImg(img, userId) { 
/*if (credentials.email === null || credentials.password === null || credentials.name === null) { 
    return Observable.throw("Please insert credentials"); 
} else {*/ 
// At this point store the credentials to your backend! 
console.log(userId); 
let options: FileUploadOptions = { 
    fileKey: 'img', 
    fileName: 'name.png', 
    params: {action: 'upload_image', api_key: API_KEY, user_id: userId}, 
    httpMethod: 'post', 
    mimeType: 'image/png' 
} 
console.log('upload function'); 
return new Promise(resolve => { 
    this.fileTransfer.upload(img, encodeURI('https://pehlayzindagi.pk/api/api.php'), options) 
    .then((data) => { 
     console.log('uploaded image'); 
     console.log('APi response is' + data.response); 

     let img = JSON.parse(data.response); 
     console.log(img.status + ' ' + img.message); 
     resolve(img) 
     // success 
    }, (err) => { 
     console.log('image failed'); 
     reject(false) 
     // error 
    }); 
}); 
// } } 

おかげ

答えて

0

Thisトピックが助けてくれたし、私は最終的に解決策を見つけました。私はこの質問に答えるので、誰かを助けることができます。あなたはオプションでこのchunkedMode = false paramを追加する必要があります。それはhttpsでも使えます。乾杯!

関連する問題