mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-16 00:11:10 +08:00
refactor(rename plugin to FileTransfer to match original plugin): (#1768)
BREAKING CHANGE: Package name is now `@ionic-native/file-transfer`. `Transfer` class has been renamed to `FileTransfer`. Also, `TransferObject` class has been renamed to `FileTransferObject`.
This commit is contained in:
parent
06e666d6a0
commit
3c54a1c7f5
@ -1,8 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CordovaInstance, Plugin, InstanceCheck, checkAvailability, IonicNativePlugin } from '@ionic-native/core';
|
import { CordovaInstance, Plugin, InstanceCheck, checkAvailability, IonicNativePlugin } from '@ionic-native/core';
|
||||||
|
|
||||||
declare const FileTransfer: any;
|
|
||||||
|
|
||||||
export interface FileUploadOptions {
|
export interface FileUploadOptions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,21 +107,21 @@ export interface FileTransferError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Transfer
|
* @name File Transfer
|
||||||
*
|
*
|
||||||
* @description
|
* @description
|
||||||
* This plugin allows you to upload and download files.
|
* This plugin allows you to upload and download files.
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* ```typescript
|
* ```typescript
|
||||||
* import { Transfer, FileUploadOptions, TransferObject } from '@ionic-native/transfer';
|
* import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/transfer';
|
||||||
* import { File } from '@ionic-native/file';
|
* import { File } from '@ionic-native/file';
|
||||||
*
|
*
|
||||||
* constructor(private transfer: Transfer, private file: File) { }
|
* constructor(private transfer: FileTransfer, private file: File) { }
|
||||||
*
|
*
|
||||||
* ...
|
* ...
|
||||||
*
|
*
|
||||||
* const fileTransfer: TransferObject = this.transfer.create();
|
* const fileTransfer: FileTransferObject = this.transfer.create();
|
||||||
*
|
*
|
||||||
* // Upload a file:
|
* // Upload a file:
|
||||||
* fileTransfer.upload(..).then(..).catch(..);
|
* fileTransfer.upload(..).then(..).catch(..);
|
||||||
@ -170,7 +168,7 @@ export interface FileTransferError {
|
|||||||
* FileUploadResult
|
* FileUploadResult
|
||||||
* FileTransferError
|
* FileTransferError
|
||||||
* @classes
|
* @classes
|
||||||
* TransferObject
|
* FileTransferObject
|
||||||
*/
|
*/
|
||||||
@Plugin({
|
@Plugin({
|
||||||
pluginName: 'FileTransfer',
|
pluginName: 'FileTransfer',
|
||||||
@ -180,7 +178,7 @@ export interface FileTransferError {
|
|||||||
platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Ubuntu', 'Windows', 'Windows Phone']
|
platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Ubuntu', 'Windows', 'Windows Phone']
|
||||||
})
|
})
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Transfer extends IonicNativePlugin {
|
export class FileTransfer extends IonicNativePlugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error code rejected from upload with FileTransferError
|
* Error code rejected from upload with FileTransferError
|
||||||
@ -202,10 +200,10 @@ export class Transfer extends IonicNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new FileTransfer object
|
* Creates a new FileTransfer object
|
||||||
* @return {TransferObject}
|
* @return {FileTransferObject}
|
||||||
*/
|
*/
|
||||||
create(): TransferObject {
|
create(): FileTransferObject {
|
||||||
return new TransferObject();
|
return new FileTransferObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -217,12 +215,12 @@ export class Transfer extends IonicNativePlugin {
|
|||||||
plugin: 'cordova-plugin-file-transfer',
|
plugin: 'cordova-plugin-file-transfer',
|
||||||
pluginName: 'FileTransfer'
|
pluginName: 'FileTransfer'
|
||||||
})
|
})
|
||||||
export class TransferObject {
|
export class FileTransferObject {
|
||||||
private _objectInstance: any;
|
private _objectInstance: any;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (checkAvailability('FileTransfer', null, 'FileTransfer') === true) {
|
if (checkAvailability(FileTransfer.getPluginRef(), null, FileTransfer.getPluginName()) === true) {
|
||||||
this._objectInstance = new FileTransfer();
|
this._objectInstance = new (FileTransfer.getPlugin())();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,9 +237,7 @@ export class TransferObject {
|
|||||||
successIndex: 2,
|
successIndex: 2,
|
||||||
errorIndex: 3
|
errorIndex: 3
|
||||||
})
|
})
|
||||||
upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise<FileUploadResult> {
|
upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise<FileUploadResult> { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads a file from server.
|
* Downloads a file from server.
|
||||||
@ -256,9 +252,7 @@ export class TransferObject {
|
|||||||
successIndex: 2,
|
successIndex: 2,
|
||||||
errorIndex: 3
|
errorIndex: 3
|
||||||
})
|
})
|
||||||
download(source: string, target: string, trustAllHosts?: boolean, options?: { [s: string]: any; }): Promise<any> {
|
download(source: string, target: string, trustAllHosts?: boolean, options?: { [s: string]: any; }): Promise<any> { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a listener that gets called whenever a new chunk of data is transferred.
|
* Registers a listener that gets called whenever a new chunk of data is transferred.
|
||||||
@ -276,5 +270,5 @@ export class TransferObject {
|
|||||||
@CordovaInstance({
|
@CordovaInstance({
|
||||||
sync: true
|
sync: true
|
||||||
})
|
})
|
||||||
abort(): void { }
|
abort(): void {}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user