类 UploadHandler

java.lang.Object
cloud.opencode.base.tool.upload.UploadHandler

public class UploadHandler extends Object
版本:
v1.0.0
作者:
Jon So, e-mail: ijonso123@gmail.com url: Jon's blog url: project github
  • 构造器详细资料

    • UploadHandler

      public UploadHandler()
  • 方法详细资料

    • getPosition

      private static Map<String,Integer> getPosition(WatermarkPosition position, int marginX, int marginY, int imgWidth, int imgHeight, int iconWidth, int iconHeight)
      get watermark position
      参数:
      position - position
      marginX - margin x
      marginY - margin y
      imgWidth - image width
      imgHeight - image height
      iconWidth - watermark width
      iconHeight - watermark height
      返回:
      map
    • downloadImage

      private static String downloadImage(String urlString) throws IOException
      Download file from web
      参数:
      urlString - URLs that begin with http or https
      返回:
      local path
      抛出:
      IOException
    • uploadFile

      public String uploadFile(org.springframework.web.multipart.MultipartFile file, OssDirectParam param) throws Exception
      Upload file to root directory. Ali OSS direct upload
      参数:
      file - file
      param - OSS param
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • uploadFile

      public String uploadFile(org.springframework.web.multipart.MultipartFile file, String savePath, OssDirectParam param) throws Exception
      Upload file to specify directory Ali OSS direct upload
      参数:
      file - file
      savePath - The name of the saved file, without the first '/'
      param - OSS param
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • uploadFile

      public String uploadFile(InputStream inputStream, String savePath, OssDirectParam param) throws Exception
      Upload file to specify directory Ali OSS direct upload
      参数:
      inputStream - file inputStream
      savePath - The name of the saved file, without the first '/'
      param - OSS param
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • uploadFile

      public String uploadFile(byte[] data, String savePath, OssDirectParam param) throws Exception
      Upload file to specify directory Ali OSS direct upload
      参数:
      data - file byte[] data
      savePath - The name of the saved file, without the first '/'
      param - OSS param
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • upImageBase

      public String upImageBase(org.springframework.web.multipart.MultipartFile file, String savePath, WatermarkType waterType, WatermarkText waterText, WatermarkImage waterImage, OssDirectParam param) throws Exception
      Upload image Ali OSS direct upload
      参数:
      file - file
      savePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpg
      waterType - watermark type
      waterText - watermark for text
      waterImage - watermark for image
      param - oss param
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • upImageBase

      public String upImageBase(InputStream inputStream, String savePath, WatermarkType waterType, WatermarkText waterText, WatermarkImage waterImage, OssDirectParam param) throws Exception
      Upload image (without check image type) Ali OSS direct upload
      参数:
      inputStream - image file inputStream.
      savePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpg
      waterType - watermark type
      waterText - watermark for text
      waterImage - watermark for image
      param - oss par
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • upImageWithWatermarkImage

      public String upImageWithWatermarkImage(org.springframework.web.multipart.MultipartFile file, String savePath, WatermarkImage image, OssDirectParam param) throws Exception
      Upload image with image watermark Ali OSS direct upload
      参数:
      file - file
      savePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpg
      image - watermark image
      param - oss param
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • upImageWithWatermarkText

      public String upImageWithWatermarkText(org.springframework.web.multipart.MultipartFile file, String savePath, WatermarkText text, OssDirectParam param) throws Exception
      Upload image with text watermark Ali OSS direct upload
      参数:
      file - file
      savePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpg
      text - watermark text
      param - oss param
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • upImage

      public String upImage(org.springframework.web.multipart.MultipartFile file, String savePath, OssDirectParam param) throws Exception
      Upload image without watermark Ali OSS direct upload
      参数:
      file - image file
      savePath - The name of the saved image, without the first '/' . ex: 20220202/001.jpg
      param - oss param
      返回:
      The full url after the upload is complete
      抛出:
      Exception
    • handleImage

      private InputStream handleImage(Image image, WatermarkType waterType, WatermarkText waterText, WatermarkImage waterImage) throws Exception
      Handle image with watermark
      参数:
      image - original image
      waterType - watermark type
      waterText - watermark for text
      waterImage - watermark for image
      返回:
      InputStream
      抛出:
      Exception
    • getSuffix

      private String getSuffix(org.springframework.web.multipart.MultipartFile file)
      Get multipartFile suffix
      参数:
      file -
      返回:
      file suffix
    • upload

      private String upload(byte[] data, String savePath, OssDirectParam ossParam)
      Upload file
      参数:
      data - byte[]
      savePath - the file save path
      ossParam - oss param
      返回:
      The full url after the upload is complete
    • upload

      private String upload(InputStream inputStream, String savePath, OssDirectParam ossParam)
      Upload file
      参数:
      inputStream - file inputStream
      savePath - the file save path
      ossParam - oss param
      返回:
      The full url after the upload is complete
    • upload

      private String upload(org.springframework.web.multipart.MultipartFile file, String savePath, OssDirectParam ossParam) throws IOException
      Upload file
      参数:
      file - multipartFile
      savePath - the file save path
      ossParam - oss param
      返回:
      The full url after the upload is complete
      抛出:
      IOException