org.jeecg.common.util.oss.OssBootUtil Java Examples

The following examples show how to use org.jeecg.common.util.oss.OssBootUtil. 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: OSSFileServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
public void upload(MultipartFile multipartFile) throws IOException {
	String fileName = multipartFile.getOriginalFilename();
	OSSFile ossFile = new OSSFile();
	ossFile.setFileName(fileName);
	String url = OssBootUtil.upload(multipartFile,"upload/test");
	ossFile.setUrl(url);
	this.save(ossFile);
}
 
Example #2
Source File: OssBootConfiguration.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Bean
public void initOssBootConfiguration() {
    OssBootUtil.setEndPoint(endpoint);
    OssBootUtil.setAccessKeyId(accessKeyId);
    OssBootUtil.setAccessKeySecret(accessKeySecret);
    OssBootUtil.setBucketName(bucketName);
    OssBootUtil.setStaticDomain(staticDomain);
}
 
Example #3
Source File: OSSFileServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Override
public boolean delete(OSSFile ossFile) {
	try {
		this.removeById(ossFile.getId());
		OssBootUtil.deleteUrl(ossFile.getUrl());
	}
	catch (Exception ex) {
		return false;
	}
	return true;
}
 
Example #4
Source File: OSSFileServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void upload(MultipartFile multipartFile) throws IOException {
	String fileName = multipartFile.getOriginalFilename();
	fileName = CommonUtils.getFileName(fileName);
	OSSFile ossFile = new OSSFile();
	ossFile.setFileName(fileName);
	String url = OssBootUtil.upload(multipartFile,"upload/test");
	ossFile.setUrl(url);
	this.save(ossFile);
}
 
Example #5
Source File: SysBaseApiImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Override
public String upload(MultipartFile file, String bizPath, String uploadType, String customBucket) {
	String url = "";
	if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
		url = MinioUtil.upload(file,bizPath,customBucket);
	}else{
		url = OssBootUtil.upload(file,bizPath,customBucket);
	}
	return url;
}
 
Example #6
Source File: SysBaseApiImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Override
public String upload(MultipartFile file,String bizPath,String uploadType) {
	String url = "";
	if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
		url = MinioUtil.upload(file,bizPath);
	}else{
		url = OssBootUtil.upload(file,bizPath);
	}
	return url;
}
 
Example #7
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 #8
Source File: OssBootConfiguration.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Bean
public void initOssBootConfiguration() {
    OssBootUtil.setEndPoint(endpoint);
    OssBootUtil.setAccessKeyId(accessKeyId);
    OssBootUtil.setAccessKeySecret(accessKeySecret);
    OssBootUtil.setBucketName(bucketName);
    OssBootUtil.setStaticDomain(staticDomain);
}
 
Example #9
Source File: OSSFileServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
public boolean delete(OSSFile ossFile) {
	try {
		this.removeById(ossFile.getId());
		OssBootUtil.deleteUrl(ossFile.getUrl());
	}
	catch (Exception ex) {
		return false;
	}
	return true;
}
 
Example #10
Source File: SysBaseApiImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public String upload(MultipartFile file,String bizPath,String uploadType) {
	String url = "";
	if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
		url = MinioUtil.upload(file,bizPath);
	}else{
		url = OssBootUtil.upload(file,bizPath);
	}
	return url;
}
 
Example #11
Source File: SysBaseApiImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
public String upload(MultipartFile file,String bizPath,String uploadType) {
	String url = "";
	if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
		url = MinioUtil.upload(file,bizPath);
	}else{
		url = OssBootUtil.upload(file,bizPath);
	}
	return url;
}
 
Example #12
Source File: CommonUtils.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
* 统一全局上传
* @Return: java.lang.String
*/
public static String upload(MultipartFile file, String bizPath, String uploadType) {
    String url = "";
    if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
        url = MinioUtil.upload(file,bizPath);
    }else{
        url = OssBootUtil.upload(file,bizPath);
    }
    return url;
}
 
Example #13
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 #14
Source File: OssBootConfiguration.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Bean
public void initOssBootConfiguration() {
    OssBootUtil.setEndPoint(endpoint);
    OssBootUtil.setAccessKeyId(accessKeyId);
    OssBootUtil.setAccessKeySecret(accessKeySecret);
    OssBootUtil.setBucketName(bucketName);
    OssBootUtil.setStaticDomain(staticDomain);
}
 
Example #15
Source File: OSSFileServiceImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public boolean delete(OSSFile ossFile) {
	try {
		this.removeById(ossFile.getId());
		OssBootUtil.deleteUrl(ossFile.getUrl());
	}
	catch (Exception ex) {
		return false;
	}
	return true;
}
 
Example #16
Source File: OSSFileServiceImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public void upload(MultipartFile multipartFile) throws IOException {
	String fileName = multipartFile.getOriginalFilename();
	fileName = CommonUtils.getFileName(fileName);
	OSSFile ossFile = new OSSFile();
	ossFile.setFileName(fileName);
	String url = OssBootUtil.upload(multipartFile,"upload/test");
	ossFile.setUrl(url);
	this.save(ossFile);
}
 
Example #17
Source File: SysBaseApiImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public String upload(MultipartFile file, String bizPath, String uploadType, String customBucket) {
	String url = "";
	if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
		url = MinioUtil.upload(file,bizPath,customBucket);
	}else{
		url = OssBootUtil.upload(file,bizPath,customBucket);
	}
	return url;
}