public class UploadHandler extends Object
| 构造器和说明 |
|---|
UploadHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
private static String |
downloadImage(String urlString)
Download file from web
|
private static Map<String,Integer> |
getPosition(WatermarkPosition position,
int marginX,
int marginY,
int imgWidth,
int imgHeight,
int iconWidth,
int iconHeight)
get watermark position
|
private String |
getSuffix(org.springframework.web.multipart.MultipartFile file)
Get multipartFile suffix
|
private InputStream |
handleImage(Image image,
WatermarkType waterType,
WatermarkText waterText,
WatermarkImage waterImage)
Handle image with watermark
|
String |
upImage(org.springframework.web.multipart.MultipartFile file,
String savePath,
OssDirectParam param)
Upload image without watermark
Ali OSS direct upload
|
String |
upImageBase(InputStream inputStream,
String savePath,
WatermarkType waterType,
WatermarkText waterText,
WatermarkImage waterImage,
OssDirectParam param)
Upload image (without check image type)
Ali OSS direct upload
|
String |
upImageBase(org.springframework.web.multipart.MultipartFile file,
String savePath,
WatermarkType waterType,
WatermarkText waterText,
WatermarkImage waterImage,
OssDirectParam param)
Upload image
Ali OSS direct upload
|
String |
upImageWithWatermarkImage(org.springframework.web.multipart.MultipartFile file,
String savePath,
WatermarkImage image,
OssDirectParam param)
Upload image with image watermark
Ali OSS direct upload
|
String |
upImageWithWatermarkText(org.springframework.web.multipart.MultipartFile file,
String savePath,
WatermarkText text,
OssDirectParam param)
Upload image with text watermark
Ali OSS direct upload
|
private String |
upload(byte[] data,
String savePath,
OssDirectParam ossParam)
Upload file
|
private String |
upload(InputStream inputStream,
String savePath,
OssDirectParam ossParam)
Upload file
|
private String |
upload(org.springframework.web.multipart.MultipartFile file,
String savePath,
OssDirectParam ossParam)
Upload file
|
String |
uploadFile(byte[] data,
String savePath,
OssDirectParam param)
Upload file to specify directory
Ali OSS direct upload
|
String |
uploadFile(InputStream inputStream,
String savePath,
OssDirectParam param)
Upload file to specify directory
Ali OSS direct upload
|
String |
uploadFile(org.springframework.web.multipart.MultipartFile file,
OssDirectParam param)
Upload file to root directory.
|
String |
uploadFile(org.springframework.web.multipart.MultipartFile file,
String savePath,
OssDirectParam param)
Upload file to specify directory
Ali OSS direct upload
|
private static Map<String,Integer> getPosition(WatermarkPosition position, int marginX, int marginY, int imgWidth, int imgHeight, int iconWidth, int iconHeight)
position - positionmarginX - margin xmarginY - margin yimgWidth - image widthimgHeight - image heighticonWidth - watermark widthiconHeight - watermark heightprivate static String downloadImage(String urlString) throws IOException
urlString - URLs that begin with http or httpsIOExceptionpublic String uploadFile(org.springframework.web.multipart.MultipartFile file, OssDirectParam param) throws Exception
file - fileparam - OSS paramExceptionpublic String uploadFile(org.springframework.web.multipart.MultipartFile file, String savePath, OssDirectParam param) throws Exception
file - filesavePath - The name of the saved file, without the first '/'param - OSS paramExceptionpublic String uploadFile(InputStream inputStream, String savePath, OssDirectParam param) throws Exception
inputStream - file inputStreamsavePath - The name of the saved file, without the first '/'param - OSS paramExceptionpublic String uploadFile(byte[] data, String savePath, OssDirectParam param) throws Exception
data - file byte[] datasavePath - The name of the saved file, without the first '/'param - OSS paramExceptionpublic String upImageBase(org.springframework.web.multipart.MultipartFile file, String savePath, WatermarkType waterType, WatermarkText waterText, WatermarkImage waterImage, OssDirectParam param) throws Exception
file - filesavePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpgwaterType - watermark typewaterText - watermark for textwaterImage - watermark for imageparam - oss paramExceptionpublic String upImageBase(InputStream inputStream, String savePath, WatermarkType waterType, WatermarkText waterText, WatermarkImage waterImage, OssDirectParam param) throws Exception
inputStream - image file inputStream.savePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpgwaterType - watermark typewaterText - watermark for textwaterImage - watermark for imageparam - oss parExceptionpublic String upImageWithWatermarkImage(org.springframework.web.multipart.MultipartFile file, String savePath, WatermarkImage image, OssDirectParam param) throws Exception
file - filesavePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpgimage - watermark imageparam - oss paramExceptionpublic String upImageWithWatermarkText(org.springframework.web.multipart.MultipartFile file, String savePath, WatermarkText text, OssDirectParam param) throws Exception
file - filesavePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpgtext - watermark textparam - oss paramExceptionpublic String upImage(org.springframework.web.multipart.MultipartFile file, String savePath, OssDirectParam param) throws Exception
file - image filesavePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpgparam - oss paramExceptionprivate InputStream handleImage(Image image, WatermarkType waterType, WatermarkText waterText, WatermarkImage waterImage) throws Exception
image - original imagewaterType - watermark typewaterText - watermark for textwaterImage - watermark for imageExceptionprivate String getSuffix(org.springframework.web.multipart.MultipartFile file)
file - private String upload(byte[] data, String savePath, OssDirectParam ossParam)
data - byte[]savePath - the file save pathossParam - oss paramprivate String upload(InputStream inputStream, String savePath, OssDirectParam ossParam)
inputStream - file inputStreamsavePath - the file save pathossParam - oss paramprivate String upload(org.springframework.web.multipart.MultipartFile file, String savePath, OssDirectParam ossParam) throws IOException
file - multipartFilesavePath - the file save pathossParam - oss paramIOExceptionCopyright © 2022. All rights reserved.