Class AttachmentApi


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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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)
      上传附件。
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AttachmentApi

        public AttachmentApi​(Context context)
    • Method Detail

      • 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();
         }
         
        Parameters:
        path - 要上传的文件的路径
        Returns:
        上传完成后返回附件的id
        See Also:
        上传附件
      • 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();
         }
         
        Parameters:
        fileId - 附件的id
        dir - 下载到哪个目录,如果不存在会自动创建
        filename - 下载到哪个文件
        Returns:
        下载完成后返回文件路径
        See Also:
        下载附件