From 4cd48b4d0e72770962857c96c001c5597b504772 Mon Sep 17 00:00:00 2001 From: MaximBelov Date: Tue, 11 Jul 2023 20:24:15 +0300 Subject: [PATCH] feat(http): onProgress param to sendRequest method (#4512) * feat(http): add onProgress callback to uploadFile and downloadFile * feat(http): add uploadFileWithOptions and downloadFileWithOptions methods * add onProgress to sendRequest --- src/@awesome-cordova-plugins/plugins/http/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/@awesome-cordova-plugins/plugins/http/index.ts b/src/@awesome-cordova-plugins/plugins/http/index.ts index dc9bc4800..44930d4f1 100644 --- a/src/@awesome-cordova-plugins/plugins/http/index.ts +++ b/src/@awesome-cordova-plugins/plugins/http/index.ts @@ -1,6 +1,11 @@ import { Injectable } from '@angular/core'; import { Cordova, CordovaProperty, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core'; +export interface OnProgress { + isProgress: boolean; + transferred: number; + total: number; +} export interface HTTPResponse { /** * The HTTP status number of the response or a negative internal error code. @@ -608,6 +613,7 @@ export class HTTP extends AwesomeCordovaNativePlugin { * @param options.filePath {string} file path(s) to be used during upload and download see uploadFile and downloadFile for detailed information * @param options.name {string} name(s) to be used during upload see uploadFile for detailed information * @param options.responseType {string} response type, defaults to text + * @param options.onProgress {function} A callback that is called when is progress * @returns {Promise} returns a promise that will resolve on success, and reject on failure */ @Cordova() @@ -623,6 +629,7 @@ export class HTTP extends AwesomeCordovaNativePlugin { filePath?: string | string[]; name?: string | string[]; responseType?: 'text' | 'arraybuffer' | 'blob' | 'json'; + onProgress?: (response: OnProgress) => void; } ): Promise { return;