nova-upload.service.d.ts 4.0 KB

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