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