public class CmsFileUtils
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static class |
CmsFileUtils.FileInfo
FileInfo 文件信息封装类
|
static class |
CmsFileUtils.FileInfoComparator |
static class |
CmsFileUtils.FileReplaceResult
FileSearchResult 文件查找结果
|
static class |
CmsFileUtils.FileSearchResult
FileSearchResult 文件查找结果
|
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String[] |
ALLOW_FILES |
static java.lang.String[] |
AUDIO_FILE_SUFFIXS |
private static CmsFileUtils.FileInfoComparator |
CREATEDATE_COMPARATOR |
static java.lang.String[] |
DOCUMENT_FILE_SUFFIXS |
static java.lang.String |
FILE_TYPE_AUDIO |
static java.lang.String |
FILE_TYPE_DOCUMENT |
static java.lang.String |
FILE_TYPE_IMAGE |
static java.lang.String |
FILE_TYPE_OTHER |
static java.lang.String |
FILE_TYPE_PDF |
static java.lang.String |
FILE_TYPE_VIDEO |
private static CmsFileUtils.FileInfoComparator |
FILENAME_COMPARATOR |
private static CmsFileUtils.FileInfoComparator |
FILESIZE_COMPARATOR |
static java.lang.String |
HEADERS_SEND_APACHE |
static java.lang.String |
HEADERS_SEND_CTRL |
static java.lang.String |
HEADERS_SEND_NGINX |
static java.lang.String[] |
IMAGE_FILE_SUFFIXS |
static java.util.List<java.lang.String> |
IMAGE_FILE_SUFFIXS_LIST |
static java.lang.String[] |
IMAGE_FILETYPES |
private static CmsFileUtils.FileInfoComparator |
MODIFIEDDATE_COMPARATOR |
static java.lang.String |
NGINX_PRIVATEFILE_PREFIX |
static java.lang.String |
ORDERFIELD_CREATEDATE |
static java.lang.String |
ORDERFIELD_FILENAME |
static java.lang.String |
ORDERFIELD_FILESIZE |
static java.lang.String |
ORDERFIELD_MODIFIEDDATE |
static java.lang.String[] |
OTHER_FILE_SUFFIXS |
static java.lang.String[] |
OTHER_FILETYPES |
static java.lang.String |
UPLOAD_PATH |
static java.lang.String |
USER_PRIVATE_PATH |
static java.lang.String[] |
VIDEO_FILE_SUFFIXS |
static java.lang.String[] |
VIDEO_FILETYPES |
限定符 | 构造器和说明 |
---|---|
private |
CmsFileUtils() |
限定符和类型 | 方法和说明 |
---|---|
static void |
copyFileToFile(java.lang.String source,
java.lang.String destination) |
static void |
copyFileToOutputStream(java.lang.String filepath,
java.io.OutputStream outputStream) |
static void |
copyInputStreamToFile(java.io.InputStream source,
java.lang.String destination) |
static boolean |
createFile(java.lang.String filepath,
java.lang.String content)
写入文件
|
static boolean |
delete(java.lang.String filepath)
移动文件或目录
|
static boolean |
exists(java.lang.String filepath) |
static java.lang.String |
getFileContent(java.lang.String filepath)
获取文件内容
|
static java.util.List<CmsFileUtils.FileInfo> |
getFileList(java.lang.String dirPath,
boolean useFilter,
java.lang.String orderField)
获取目录下文件列表
|
static java.util.List<CmsFileUtils.FileInfo> |
getFileList(java.lang.String dirPath,
java.lang.String orderField)
获取目录下文件列表
|
static java.lang.String |
getFileName(java.lang.String filePath)
获取文件名
|
private static FileUploadResult |
getFileSize(java.io.File file,
java.lang.String filename,
java.lang.String suffix) |
static FileUploadResult |
getFileSize(java.lang.String filepath,
java.lang.String filename,
java.lang.String suffix) |
static java.lang.String |
getFileType(java.lang.String suffix) |
static java.lang.String |
getPrivateFileSignString(long expiry,
java.lang.String filepath)
获取私有文件前面字符串
|
static java.lang.String |
getSafeFileName(java.lang.String path) |
static java.lang.String |
getSuffix(java.lang.String originalFilename)
获取文件后缀
|
static java.lang.String |
getUploadFileName(java.lang.String suffix)
获取文件名
|
static java.lang.String |
getUserPrivateFileName(long userId,
java.lang.String filepath)
获取用户私有文件名
|
static boolean |
isDirectory(java.lang.String filepath) |
static boolean |
isFile(java.lang.String filepath) |
private static boolean |
isSafe(java.util.List<org.apache.pdfbox.cos.COSObject> pdfObjects) |
static boolean |
isSafe(java.lang.String filepath,
java.lang.String suffix)
获取文件内容
|
static void |
mkdirs(java.lang.String filepath) |
static void |
mkdirsParent(java.lang.String filepath) |
static boolean |
moveFile(java.lang.String filepath,
java.lang.String backupFilePath)
移动文件或目录
|
static void |
replaceFileList(java.lang.String dirPath,
java.util.List<CmsFileUtils.FileReplaceResult> fileList,
java.lang.String word,
java.lang.String replace)
获取目录下文件列表
|
private static void |
searchFileList(java.nio.file.Path dirPath,
java.lang.String parentPath,
java.lang.String word,
java.util.List<CmsFileUtils.FileSearchResult> fileList)
获取目录下文件列表
|
static java.util.List<CmsFileUtils.FileSearchResult> |
searchFileList(java.lang.String dirPath,
java.lang.String parentPath,
java.lang.String word)
获取目录下文件列表
|
static boolean |
updateFile(java.lang.String filepath,
java.lang.String historyFilePath,
java.lang.String content)
修改文件内容
|
static java.lang.String |
upload(byte[] data,
java.lang.String fileName)
上传文件
|
static java.lang.String |
upload(byte[] data,
java.lang.String fileName,
java.lang.String originalName,
java.lang.String metadataPath)
上传文件
|
static java.nio.file.Path |
upload(org.springframework.web.multipart.MultipartFile file,
java.lang.String fileName)
上传文件
|
static void |
writeByteArrayToFile(java.lang.String filepath,
byte[] data) |
public static final java.lang.String UPLOAD_PATH
public static final java.lang.String USER_PRIVATE_PATH
public static final java.lang.String HEADERS_SEND_CTRL
public static final java.lang.String HEADERS_SEND_NGINX
public static final java.lang.String HEADERS_SEND_APACHE
public static final java.lang.String NGINX_PRIVATEFILE_PREFIX
public static final java.lang.String ORDERFIELD_FILENAME
public static final java.lang.String ORDERFIELD_FILESIZE
public static final java.lang.String ORDERFIELD_CREATEDATE
public static final java.lang.String ORDERFIELD_MODIFIEDDATE
private static final CmsFileUtils.FileInfoComparator FILENAME_COMPARATOR
private static final CmsFileUtils.FileInfoComparator FILESIZE_COMPARATOR
private static final CmsFileUtils.FileInfoComparator CREATEDATE_COMPARATOR
private static final CmsFileUtils.FileInfoComparator MODIFIEDDATE_COMPARATOR
public static final java.util.List<java.lang.String> IMAGE_FILE_SUFFIXS_LIST
public static final java.lang.String[] AUDIO_FILE_SUFFIXS
public static final java.lang.String[] IMAGE_FILE_SUFFIXS
public static final java.lang.String[] DOCUMENT_FILE_SUFFIXS
public static final java.lang.String[] VIDEO_FILE_SUFFIXS
public static final java.lang.String[] OTHER_FILE_SUFFIXS
public static final java.lang.String[] ALLOW_FILES
public static final java.lang.String[] IMAGE_FILETYPES
public static final java.lang.String[] OTHER_FILETYPES
public static final java.lang.String[] VIDEO_FILETYPES
public static final java.lang.String FILE_TYPE_IMAGE
public static final java.lang.String FILE_TYPE_VIDEO
public static final java.lang.String FILE_TYPE_DOCUMENT
public static final java.lang.String FILE_TYPE_AUDIO
public static final java.lang.String FILE_TYPE_OTHER
public static final java.lang.String FILE_TYPE_PDF
public static java.util.List<CmsFileUtils.FileInfo> getFileList(java.lang.String dirPath, java.lang.String orderField)
dirPath
- orderField
- public static java.util.List<CmsFileUtils.FileSearchResult> searchFileList(java.lang.String dirPath, java.lang.String parentPath, java.lang.String word)
dirPath
- parentPath
- word
- public static void replaceFileList(java.lang.String dirPath, java.util.List<CmsFileUtils.FileReplaceResult> fileList, java.lang.String word, java.lang.String replace)
dirPath
- fileList
- word
- replace
- private static void searchFileList(java.nio.file.Path dirPath, java.lang.String parentPath, java.lang.String word, java.util.List<CmsFileUtils.FileSearchResult> fileList)
dirPath
- parentPath
- word
- fileList
- public static java.util.List<CmsFileUtils.FileInfo> getFileList(java.lang.String dirPath, boolean useFilter, java.lang.String orderField)
dirPath
- useFilter
- orderField
- public static void writeByteArrayToFile(java.lang.String filepath, byte[] data) throws java.io.IOException
filepath
- data
- java.io.IOException
public static FileUploadResult getFileSize(java.lang.String filepath, java.lang.String filename, java.lang.String suffix)
filepath
- filename
- suffix
- private static FileUploadResult getFileSize(java.io.File file, java.lang.String filename, java.lang.String suffix)
file
- suffix
- public static void copyInputStreamToFile(java.io.InputStream source, java.lang.String destination) throws java.io.IOException
source
- destination
- java.io.IOException
public static void copyFileToFile(java.lang.String source, java.lang.String destination) throws java.io.IOException
source
- destination
- java.io.IOException
public static void copyFileToOutputStream(java.lang.String filepath, java.io.OutputStream outputStream) throws java.io.IOException
filepath
- outputStream
- java.io.IOException
public static void mkdirs(java.lang.String filepath)
filepath
- public static void mkdirsParent(java.lang.String filepath)
filepath
- public static boolean isDirectory(java.lang.String filepath)
filepath
- public static boolean isFile(java.lang.String filepath)
filepath
- public static boolean exists(java.lang.String filepath)
filepath
- public static boolean createFile(java.lang.String filepath, java.lang.String content) throws java.io.IOException
filepath
- content
- java.io.IOException
public static boolean moveFile(java.lang.String filepath, java.lang.String backupFilePath)
filepath
- backupFilePath
- public static java.lang.String getSafeFileName(java.lang.String path)
path
- public static boolean delete(java.lang.String filepath)
filepath
- public static boolean updateFile(java.lang.String filepath, java.lang.String historyFilePath, java.lang.String content) throws java.io.IOException
filepath
- historyFilePath
- content
- java.io.IOException
public static boolean isSafe(java.lang.String filepath, java.lang.String suffix)
filepath
- suffix
- private static boolean isSafe(java.util.List<org.apache.pdfbox.cos.COSObject> pdfObjects)
public static java.lang.String getFileContent(java.lang.String filepath)
filepath
- public static java.lang.String getUploadFileName(java.lang.String suffix)
suffix
- public static java.lang.String getPrivateFileSignString(long expiry, java.lang.String filepath)
expiry
- filepath
- public static java.lang.String getUserPrivateFileName(long userId, java.lang.String filepath)
userId
- filepath
- public static java.lang.String getFileName(java.lang.String filePath)
filePath
- public static java.lang.String getSuffix(java.lang.String originalFilename)
originalFilename
- public static java.lang.String getFileType(java.lang.String suffix)
public static java.lang.String upload(byte[] data, java.lang.String fileName) throws java.lang.IllegalStateException, java.io.IOException
data
- fileName
- java.lang.IllegalStateException
java.io.IOException
public static java.lang.String upload(byte[] data, java.lang.String fileName, java.lang.String originalName, java.lang.String metadataPath) throws java.lang.IllegalStateException, java.io.IOException
data
- fileName
- originalName
- metadataPath
- java.lang.IllegalStateException
java.io.IOException
public static java.nio.file.Path upload(org.springframework.web.multipart.MultipartFile file, java.lang.String fileName) throws java.io.IOException
file
- fileName
- java.io.IOException