类 AttachmentApi


  • public class AttachmentApi
    extends java.lang.Object
    附件API TODO: 支持上传和下载带有密码的附件
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      reactor.core.publisher.Mono<java.nio.file.Path> downloadFile​(java.lang.String fileId, java.nio.file.Path dir, java.lang.String filename)
      下载附件。
      reactor.core.publisher.Mono<EMAttachment> uploadFile​(java.nio.file.Path path)
      上传附件。
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • AttachmentApi

        public AttachmentApi​(Context context)
    • 方法详细资料

      • uploadFile

        public reactor.core.publisher.Mono<EMAttachment> uploadFile​(java.nio.file.Path path)
        上传附件。

        API使用示例:

         
         EMService service;
         Path uploadPath = Paths.get("/local/path/.../icon_180.png");
         try {
             EMAttachment attachment = service.attachment().uploadFile(uploadPath).block();
             String fileId = attachment.getId();
             String url = attachment.getUrl();
             String secret = attachment.getSecret();
         } catch (EMException e) {
             e.getErrorCode();
             e.getMessage();
         }
         
        参数:
        path - 要上传的文件的路径
        返回:
        上传完成后返回附件的id
        另请参阅:
        上传附件
      • downloadFile

        public reactor.core.publisher.Mono<java.nio.file.Path> downloadFile​(java.lang.String fileId,
                                                                            java.nio.file.Path dir,
                                                                            java.lang.String filename)
        下载附件。

        API使用示例:

         
         EMService service;
         try {
             Path downloadPath = Paths.get("/local/path/...");
             Path path = service.attachment().downloadFile("fileId", downloadPath, "filename").block();
         } catch (EMException e) {
             e.getErrorCode();
             e.getMessage();
         }
         
        参数:
        fileId - 附件的id
        dir - 下载到哪个目录,如果不存在会自动创建
        filename - 下载到哪个文件
        返回:
        下载完成后返回文件路径
        另请参阅:
        下载附件