mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-29 22:27:33 +00:00
[Change] Framework-API 在 MessageSender 中的 'uploadImage(File)' 增加对文件存在与否的检查;
[Change] MessageSender 增加文件存在与否的检查;
This commit is contained in:
parent
a4ff698716
commit
a9b693a0a5
@ -20,10 +20,7 @@ package net.lamgc.cgj.bot.framework.message;
|
||||
import net.lamgc.cgj.bot.framework.Platform;
|
||||
import net.lamgc.cgj.bot.framework.message.exception.UploadImageException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* 消息发送者.
|
||||
@ -109,6 +106,9 @@ public interface MessageSender {
|
||||
* @throws UploadImageException 如果图片上传时发生异常可抛出.
|
||||
*/
|
||||
default String uploadImage(File imageFile) throws UploadImageException {
|
||||
if (!imageFile.exists()) {
|
||||
throw new UploadImageException(new FileNotFoundException(imageFile.getAbsolutePath()));
|
||||
}
|
||||
try (InputStream imageInput = new FileInputStream(imageFile)) {
|
||||
return uploadImage(imageInput);
|
||||
} catch(Exception e) {
|
||||
|
Loading…
Reference in New Issue
Block a user