nova-upload.service.d.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import { Platform } from '@ionic/angular';
  2. import Parse from "parse";
  3. import { Diagnostic } from '@awesome-cordova-plugins/diagnostic/ngx';
  4. /**
  5. * MediaCapture插件
  6. * @private
  7. * @description
  8. * 依赖:File
  9. * npm i -S cordova-plugin-file @awesome-cordova-plugins/file
  10. */
  11. import { MediaFile } from "@awesome-cordova-plugins/media-capture";
  12. import * as i0 from "@angular/core";
  13. /**
  14. * NovaFile 文件类型
  15. * @public
  16. */
  17. export interface NovaFile {
  18. id: string;
  19. key: string;
  20. url: string;
  21. name: string;
  22. type: string;
  23. size: number;
  24. md5?: string;
  25. }
  26. /**
  27. * NovaUploadService 上传服务
  28. * @public
  29. */
  30. export declare class NovaUploadService {
  31. private platform;
  32. private diagnostic;
  33. company: string;
  34. uptoken: string;
  35. qiniuConf: any;
  36. domain: string;
  37. constructor(platform: Platform, diagnostic: Diagnostic);
  38. /**
  39. * 全端通用上传方法
  40. * @params file:File 待上传文件
  41. * @params onProgress:Function 上传进度回调函数
  42. * @returns
  43. * progressData {
  44. "total": {
  45. "size": 8491,
  46. "loaded": 8490,
  47. "percent": 99.98822282416675
  48. }
  49. }
  50. * novafileData {
  51. "id":"xxxxxxxxxx" // Attachment.objectId
  52. "hash": "FoYHjpyTif1t8uOMv6N6sVIeGTvq",
  53. "key": "E4KpGvTEto/20230901/053605467.jpg",
  54. "url": "https://file-cloud.fmode.cn/E4KpGvTEto/20230901/053605467.jpg",
  55. "name": "20230901173605.jpg",
  56. "type": "image/jpg",
  57. "size": 7853
  58. }
  59. */
  60. upload(file: File, onProgress?: Function): Promise<NovaFile>;
  61. /**
  62. * 移动端上传专用方法
  63. * @returns
  64. */
  65. isCapacitor(): boolean;
  66. requestPermission(): Promise<void>;
  67. requestStoagePermission(): Promise<void>;
  68. requestCameraPermission(): Promise<void>;
  69. /**
  70. * 上传Token获取方法
  71. * @returns
  72. */
  73. getUptoken(refresh?: boolean): Promise<void>;
  74. /**
  75. * 生成文件上传Key值:<公司id>/<yyyymmdd>/<file.id><hhMMss>.<ext>
  76. * @desc 用于对象存储含全路径的文件名称
  77. */
  78. genFileKey(file: {
  79. id: string;
  80. name: string;
  81. }, company?: any): string;
  82. /**
  83. * 获取当前登录用户公司ID
  84. * @returns 公司ID
  85. */
  86. getCompanyId(): string;
  87. qiniuDomain: string;
  88. queryDomain(): Promise<void>;
  89. /**
  90. * 保存上传信息至附件表 Attachment
  91. * @param file 附件信息
  92. * @returns attachment Parse.Object
  93. */
  94. saveAttachment(file: NovaFile | {
  95. url: string;
  96. size: string;
  97. name: string;
  98. type: string;
  99. md5?: string;
  100. }, domain: any, cateId?: any, company?: any): Promise<Parse.Object>;
  101. /**
  102. * 录像并上传
  103. */
  104. captureVideo(conf: any): Promise<any>;
  105. cameraCaptureVideoFile(): Promise<MediaFile | any | null>;
  106. getMediaFileDataString(mediafile: any): Promise<Blob>;
  107. /**
  108. * 拍照并上传
  109. * @returns -- {hash?:string,url:string,name:string,size:number,key:stirng}
  110. */
  111. takePicture(conf: any): Promise<any>;
  112. cameraTakePictureDataUrl(): Promise<import("@capacitor/camera").Photo>;
  113. maxSize: number;
  114. /**
  115. * 七牛上传函数:无需前端组件
  116. * @param imageBlob: Blob
  117. * @param format: string
  118. */
  119. saveQiniuImageFile(imageBlob: Blob, format: string, company?: string, onProgress?: Function): Promise<NovaFile | any>;
  120. saveQiniuMediaFile(mediafile: any, fileBlob: Blob, company?: string, onProgress?: Function): Promise<NovaFile | any>;
  121. base64ToBlobType(string: any, type: any): Promise<Blob>;
  122. base64ToBlob(base64Img: string): Promise<Blob>;
  123. fileToBlob(file: File): Blob;
  124. genMd5(inputString: string): string;
  125. static ɵfac: i0.ɵɵFactoryDeclaration<NovaUploadService, never>;
  126. static ɵprov: i0.ɵɵInjectableDeclaration<NovaUploadService>;
  127. }