How to use the ionic-native.Transfer function in ionic-native

To help you get started, we’ve selected a few ionic-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lockeyo / Graphcool-Ionic-Instagram-Clone / src / pages / camera / camera.ts View on Github external
postFile(targetPathURL){
      // new Transfer
      const fileTransfer = new Transfer();

      // URL
      var urlTo = "https://api.graph.cool/file/v1/ciz5dctr01prd015261q0o8jd";

      // File for Upload
      var targetPath = targetPathURL;

      // File name only
      var extension = targetPath.split(".").pop();
      var filepart = "image";
      var filename = filepart + "." + extension;

      var options = {
                      fileKey: "data",
                      fileName: filename,
                      chunkedMode: false,
github thomasgazzoni / ng2-platform / src / download / download.ionic.ts View on Github external
public download(fileUrl: string, fileName: string): Observable {

        const fileTransfer = new Transfer();
        const uri = `https:${fileUrl}?filename=${encodeURI(fileName)}`;
        const targetUri = `${window.cordova.file.externalDataDirectory}${fileName}`;

        fileTransfer.onProgress((event) => {
            // console.debug('download onProgress:', event.loaded, event.total);
        });

        return Observable
            .create((observer: Observer) => {

                fileTransfer.download(
                    uri,
                    targetUri)
                    .then((entry) => {
                        // console.debug('download complete: ' + entry.toURL());
                        // FileOpener.open(entry.toURL(), 'application/');
github apppresser / ap3 / app / providers / camera / app-camera.ts View on Github external
uploadPhoto(imageURI) {

    let fileTransfer = new Transfer();

    this.iframedoc = document.getElementById('ap3-iframe').contentWindow.document;
    let iframewin = document.getElementById('ap3-iframe').contentWindow.window;

    console.log('imageURI', imageURI);

    let image = imageURI.substr(imageURI.lastIndexOf('/') + 1);

    let name = image.split("?")[0];
    let anumber = image.split("?")[1];
    let ajaxurl = iframewin.apppCore.ajaxurl;

    if ('Android' === Device.device.platform) {
      image = anumber + '.jpg';
    }
github zyra / ionic-image-loader / src / providers / image-loader.ts View on Github external
private downloadImage(imageUrl: string, localPath: string): Promise {
    let transfer = new Transfer();
    return transfer.download(imageUrl, localPath);
  }
github thomasgazzoni / ng2-platform / src / upload / upload.ionic.ts View on Github external
const uploadProgress = new Subject();

        const result: IUploadResult = {
            uploadResult$: undefined,
            uploadProgress$: uploadProgress.asObservable(),
            abort: undefined,
        };

        const options: FileUploadOptions = {
            httpMethod: 'POST',
            fileKey: fieldName,
            headers: this.apiUploadHeaders,
        };

        const fileTransfer = new Transfer();

        fileTransfer.onProgress((event) => {

            const percent = Math.round((event.loaded / event.total) * 100);
            uploadProgress.next(percent);

            if (percent === 100) {
                Observable
                    .interval(150)
                    .take(10)
                    .map(value => value * 10)
                    .subscribe(value => uploadProgress.next(value));
            }

        });
github dtaalbers / ionic-example-app / file-transfer-upload / app / pages / uploading / uploading.ts View on Github external
upload = (image: string) : void => { 
        let ft = new Transfer();
        let filename = _.uniqueId() + ".jpg";
        let options = {
            fileKey: 'file',
            fileName: filename,
            mimeType: 'image/jpeg',
            chunkedMode: false,
            headers: {
                'Content-Type' : undefined
            },
            params: {
                fileName: filename
            }
        }; 
        ft.onProgress(this.onProgress);
        ft.upload(image, "http://services.dtaalbers.com/staging/pictures", options, false)
        .then((result: any) => {