2
我正在將文件傳輸到網址,我可以成功地做到這一點,但我不知道如何獲取已上傳文件的進度,我需要在某些方面取得進展數字如何在上傳文件時添加進度條
fileTransfer.upload(file_path, api_endpoint, options, data)
.then((data) => {
// success
console.log("success", JSON.parse(data['response']));
this.upload_success();
}, (err) => {
// error
this.failed_upload();
console.log('File failed uploaded.', err);
})
我發現onProgress(監聽)check ionic2文檔我不知道如何使用可能有人給我一些例子
fileTransfer.onProgress = function(progressEvent) {
if (progressEvent) {
console.log("progress success =====")
} else {
console.log("progress error =====")
}
};
如果我運行,我看不到任何這些控制檯,我在文件傳輸代碼下面添加了這個新代碼。可有一個人幫我
有[在文檔]爲例(https://github.com/apache/cordova-plugin-file-transfer#example-with-upload-headers-and-progress-events-android-and-ios-only),它使用'onprogress'方法 – Und3rTow
你告訴我它是如何工作的以及將它放在上面的代碼中@ Und3rTow –