public class AttachmentApi extends Object
| 构造器和说明 |
|---|
AttachmentApi(Context context) |
| 限定符和类型 | 方法和说明 |
|---|---|
reactor.core.publisher.Mono<Path> |
downloadFile(String fileId,
Path dir,
String filename)
下载附件。
|
reactor.core.publisher.Mono<EMAttachment> |
uploadFile(Path path)
上传附件。
|
public AttachmentApi(Context context)
public reactor.core.publisher.Mono<EMAttachment> uploadFile(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 - 要上传的文件的路径public reactor.core.publisher.Mono<Path> downloadFile(String fileId, Path dir, 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 - 附件的iddir - 下载到哪个目录,如果不存在会自动创建filename - 下载到哪个文件Copyright © 2024. All rights reserved.