日志文件存储.

This commit is contained in:
lijiahang
2024-03-12 10:58:20 +08:00
parent 5349237fb3
commit 779a84ae25
14 changed files with 149 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
package com.orion.ops.framework.common.file;
import java.io.InputStream;
import java.io.OutputStream;
/**
* 文件客户端
@@ -65,8 +66,6 @@ public interface FileClient {
*/
String upload(String path, InputStream in, boolean autoClose, boolean overrideIfExist) throws Exception;
// TODO getOutputStream
/**
* 检查文件是否存在
*
@@ -102,4 +101,23 @@ public interface FileClient {
*/
InputStream getContentInputStream(String path) throws Exception;
/**
* 获取文件输出流
*
* @param path path
* @return stream
* @throws Exception Exception
*/
OutputStream getContentOutputStream(String path) throws Exception;
/**
* 获取文件输出流
*
* @param path path
* @param append append
* @return stream
* @throws Exception Exception
*/
OutputStream getContentOutputStream(String path, boolean append) throws Exception;
}

View File

@@ -4,6 +4,7 @@ import com.orion.lang.utils.Exceptions;
import com.orion.ops.framework.common.file.FileClient;
import java.io.InputStream;
import java.io.OutputStream;
/**
* 文件客户端工具
@@ -85,8 +86,6 @@ public class FileClientUtils {
return delegate.upload(path, in, autoClose, overrideIfExist);
}
// TODO getOutputStream
/**
* 检查文件是否存在
*
@@ -130,6 +129,29 @@ public class FileClientUtils {
return delegate.getContentInputStream(path);
}
/**
* 获取文件输出流
*
* @param path path
* @return stream
* @throws Exception Exception
*/
public static OutputStream getContentOutputStream(String path) throws Exception {
return delegate.getContentOutputStream(path);
}
/**
* 获取文件输出流
*
* @param path path
* @param append append
* @return stream
* @throws Exception Exception
*/
public static OutputStream getContentOutputStream(String path, boolean append) throws Exception {
return delegate.getContentOutputStream(path, append);
}
public static void setDelegate(FileClient delegate) {
if (FileClientUtils.delegate != null) {
// unmodified