JMSGFileContent.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // JMSGFileContent.h
  3. // JMessage
  4. //
  5. // Created by deng on 16/7/4.
  6. // Copyright © 2016年 HXHG. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <JMessage/JMSGMediaAbstractContent.h>
  10. /*!
  11. * 文件内容类型
  12. */
  13. @interface JMSGFileContent : JMSGMediaAbstractContent<NSCopying>
  14. JMSG_ASSUME_NONNULL_BEGIN
  15. /*!
  16. * @abstract 文件名
  17. */
  18. @property(nonatomic, copy, readonly) NSString *fileName;
  19. /*!
  20. * @abstract 文件格式
  21. *
  22. * 注意:格式后缀不需要带点,只需后缀名,如:pdf、doc 等
  23. */
  24. @property(nonatomic, strong) NSString * JMSG_NULLABLE format;
  25. // 不支持使用的初始化方法
  26. - (nullable instancetype)init NS_UNAVAILABLE;
  27. /**
  28. * 初始化文件内容
  29. *
  30. * @param data 文件数据
  31. * @param fileName 文件名
  32. *
  33. */
  34. - (instancetype)initWithFileData:(NSData *)data
  35. fileName:(NSString *)fileName;
  36. /*!
  37. * @abstract 获取文件内容的数据
  38. */
  39. - (void)fileData:(JMSGAsyncDataHandler)handler;
  40. /*!
  41. * @abstract 获取文件内容的数据
  42. *
  43. * @param progressHandler 下载进度。会持续回调更新进度, 直接下载完成。如果为 nil 则表示不关心进度。
  44. * @param handler 结果回调。回调参数:
  45. *
  46. * - data 文件数据;
  47. * - objectId 消息msgId;
  48. * - error 不为nil表示出错;
  49. *
  50. * 如果 error 为 ni, data 也为 nil, 表示没有数据.
  51. *
  52. * @discussion
  53. * 如果本地数据文件已经存在, 则直接返回;
  54. * 如果本地还没有文件,会发起网络请求下载。下载完后再回调。
  55. */
  56. - (void)fileDataWithProgress:(JMSGMediaProgressHandler JMSG_NULLABLE)progressHandler
  57. completionHandler:(JMSGAsyncDataHandler JMSG_NULLABLE)handler;
  58. JMSG_ASSUME_NONNULL_END
  59. @end