Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(preview-any-file): add new methods for preview-any-file cordova #3643

Merged
merged 3 commits into from
Apr 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/@ionic-native/plugins/preview-any-file/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';

export interface PreviewAnyFileOptions {
/**
* The name of the file to preview.
*/
name?: string;
/**
* The mime type of the file to preview.
*/
mimeType: string;
}


/**
* @name PreviewAnyFile
* @description
Expand All @@ -22,7 +35,18 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
* .catch((error: any) => console.error(error));
*
* ```
*
*
* ...
*
*
* this.previewAnyFile.previewPath('http://www.domain.com/samplefile')
* .then((res: any) => console.log(res))
* .catch((error: any) => console.error(error));
*
* ```
*/

@Plugin({
pluginName: 'PreviewAnyFile',
plugin: 'cordova-plugin-preview-any-file', // npm package name, example: cordova-plugin-camera
Expand All @@ -43,4 +67,34 @@ export class PreviewAnyFile extends IonicNativePlugin {
preview(url: string): Promise<string> {
return;
}

/**
* previewPath function will return success callback if the file successfully opened, if the content is base64 you have to use previewBase64 method
* @param base64 {String} base64 string content
* @param options {PreviewAnyFileOptions} define the name of the file with extension or it's mimeType, if the correct extension not exist in the path
*/
@Cordova()
previewBase64(base64: string,options?: PreviewAnyFileOptions): Promise<string> {
return;
}

/**
* previewPath function will return success callback if the file successfully opened, if the content is base64 you have to use previewBase64 method
* @param url {String} full absolute URL -> file://, content://, http://, https, ... etc, if extension not exist, you must define it in the opt param
* @param options {PreviewAnyFileOptions} define the name of the file with extension or it's mimeType, if the correct extension not exist in the path
*/
@Cordova()
previewPath(url: string,options?: PreviewAnyFileOptions): Promise<string> {
return;
}

/**
* previewPath function will return success callback if the file successfully opened, if the content is base64 you have to use previewBase64 method
* @param url {String} full absolute URL -> file://, content://, http://, https, ... etc, if extension not exist, you must define it in the opt param
* @param options {PreviewAnyFileOptions} define the name of the file with extension or it's mimeType, if the correct extension not exist in the path
*/
@Cordova()
previewAsset(url: string,options?: PreviewAnyFileOptions): Promise<string> {
return;
}
}