Advertisement
Guest User

filetransfer Provider

a guest
Mar 21st, 2017
154
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Injectable } from '@angular/core';
  2. import { Http } from '@angular/http';
  3. import 'rxjs/add/operator/map';
  4. import { Transfer, FileUploadOptions, TransferObject } from '@ionic-native/transfer';
  5. import { File } from '@ionic-native/file';
  6.  
  7. /*
  8. Generated class for the FileTransferProv provider.
  9.  
  10. See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  11. for more info on providers and Angular 2 DI.
  12. */
  13. declare var FileTransfer;
  14.  
  15. @Injectable()
  16. export class FileTransferProv {
  17.  
  18. options: FileUploadOptions = {}
  19.  
  20. // fileTransfer: any;
  21.  
  22. constructor(private transfer: Transfer, private file: File) {
  23. console.log('Hello FileTransfer Provider');
  24.  
  25. }
  26.  
  27.  
  28.  
  29. upload(audioPath, name, score) {
  30. const fileTransfer: TransferObject = this.transfer.create();
  31.  
  32. let options: FileUploadOptions = {
  33. fileKey: 'file',
  34. fileName: 'name.jpg',
  35. mimeType: "audio/mp3",
  36. headers: {},
  37. params: {
  38. name: name,
  39. score: score
  40. // deviceToken: deviceToken,
  41. // devicePlatform: devicePlatform
  42. }
  43. }
  44.  
  45.  
  46. fileTransfer.upload('audioPath', 'http://pedosito.comercio365.com/uploadFile.php', options).then((data) => {
  47. console.log("Archivo Subido con Exito: " + data);
  48. }, (err) => {
  49. console.log(err);
  50. })
  51. }
  52. }
Advertisement
RAW Paste Data Copied
Advertisement