Java Code Examples for org.jeecgframework.poi.util.PoiPublicUtil#getFileExtendName()

The following examples show how to use org.jeecgframework.poi.util.PoiPublicUtil#getFileExtendName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonUtils.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
public static String uploadOnlineImage(byte[] data,String basePath,String bizPath,String uploadType){
    String dbPath = null;
    String fileName = "image" + Math.round(Math.random() * 100000000000L);
    fileName += "." + PoiPublicUtil.getFileExtendName(data);
    try {
        if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
            File file = new File(basePath + File.separator + bizPath + File.separator );
            if (!file.exists()) {
                file.mkdirs();// 创建文件根目录
            }
            String savePath = file.getPath() + File.separator + fileName;
            File savefile = new File(savePath);
            FileCopyUtils.copy(data, savefile);
            dbPath = bizPath + File.separator + fileName;
        }else {
            InputStream in = new ByteArrayInputStream(data);
            String relativePath = bizPath+"/"+fileName;
            if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
                dbPath = MinioUtil.upload(in,relativePath);
            }else if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){
                dbPath = OssBootUtil.upload(in,relativePath);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dbPath;
}
 
Example 2
Source File: ExcelExportBase.java    From autopoi with Apache License 2.0 5 votes vote down vote up
/**
 * 获取图片类型,设置图片插入类型
 * 
 * @param value
 * @return
 * @Author JEECG
 * @date 2013年11月25日
 */
public int getImageType(byte[] value) {
	String type = PoiPublicUtil.getFileExtendName(value);
	if (type.equalsIgnoreCase("JPG")) {
		return Workbook.PICTURE_TYPE_JPEG;
	} else if (type.equalsIgnoreCase("PNG")) {
		return Workbook.PICTURE_TYPE_PNG;
	}
	return Workbook.PICTURE_TYPE_JPEG;
}
 
Example 3
Source File: CommonUtils.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
public static String uploadOnlineImage(byte[] data,String basePath,String bizPath,String uploadType){
    String dbPath = null;
    String fileName = "image" + Math.round(Math.random() * 100000000000L);
    fileName += "." + PoiPublicUtil.getFileExtendName(data);
    try {
        if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
            File file = new File(basePath + File.separator + bizPath + File.separator );
            if (!file.exists()) {
                file.mkdirs();// 创建文件根目录
            }
            String savePath = file.getPath() + File.separator + fileName;
            File savefile = new File(savePath);
            FileCopyUtils.copy(data, savefile);
            dbPath = bizPath + File.separator + fileName;
        }else {
            InputStream in = new ByteArrayInputStream(data);
            String relativePath = bizPath+"/"+fileName;
            if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
                dbPath = MinioUtil.upload(in,relativePath);
            }else if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){
                dbPath = OssBootUtil.upload(in,relativePath);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dbPath;
}
 
Example 4
Source File: ExcelExportBase.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 获取图片类型,设置图片插入类型
 * 
 * @param value
 * @return
 * @Author JueYue
 * @date 2013年11月25日
 */
public int getImageType(byte[] value) {
	String type = PoiPublicUtil.getFileExtendName(value);
	if (type.equalsIgnoreCase("JPG")) {
		return Workbook.PICTURE_TYPE_JPEG;
	} else if (type.equalsIgnoreCase("PNG")) {
		return Workbook.PICTURE_TYPE_PNG;
	}
	return Workbook.PICTURE_TYPE_JPEG;
}
 
Example 5
Source File: ExcelExportBase.java    From easypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 获取图片类型,设置图片插入类型
 * 
 * @param value
 * @return
 * @Author JueYue
 * @date 2013年11月25日
 */
public int getImageType(byte[] value) {
    String type = PoiPublicUtil.getFileExtendName(value);
    if (type.equalsIgnoreCase("JPG")) {
        return Workbook.PICTURE_TYPE_JPEG;
    } else if (type.equalsIgnoreCase("PNG")) {
        return Workbook.PICTURE_TYPE_PNG;
    }
    return Workbook.PICTURE_TYPE_JPEG;
}