| | |
| | | import com.aliyun.oss.OSSException; |
| | | import com.obs.services.exception.ObsException; |
| | | import com.obs.services.model.PutObjectResult; |
| | | import com.qxueyou.scc.base.model.CacheConstants; |
| | | import com.qxueyou.scc.base.model.FileMeta; |
| | | import com.qxueyou.scc.base.model.Result; |
| | | import com.qxueyou.scc.base.util.ClientUtils; |
| | | import com.qxueyou.scc.base.util.UUIDUtils; |
| | | import com.qxueyou.scc.teach.res.service.HweiYunOBSService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.LogManager; |
| | |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | if (ObjectUtils.isEmpty(file) || file.getSize() <= 0) { |
| | | return null; |
| | | } |
| | | // if (FileUtil.isEmpty(file)) { |
| | | // return new Result(false,"文件为空"); |
| | | // } |
| | | final List<FileMeta> test = hweiYunOBSService.fileUpload(file, file.getOriginalFilename()); |
| | | String originalFilename = file.getOriginalFilename(); |
| | | String substring = originalFilename.substring(originalFilename.indexOf(".")+1); |
| | | |
| | | StringBuffer path=new StringBuffer(); |
| | | //识别文件后缀格式,获取对应的文件存储路径 |
| | | String pathFile = CacheConstants.fileFormatMap.get(substring.toUpperCase(Locale.ROOT)); |
| | | if (StringUtils.isEmpty(pathFile)) {//如果为空则上传到默认存储文件夹 |
| | | path.append(CacheConstants.GUANGXI_ACQUIESCE); |
| | | }else{ |
| | | path.append(pathFile); |
| | | } |
| | | String uuid = UUIDUtils.UUID(); |
| | | //将文件重新命名,防止出现重名覆盖 |
| | | String newFilename=uuid.concat(file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."))); |
| | | final List<FileMeta> test = hweiYunOBSService.fileUpload(file,path.append(newFilename).toString()); |
| | | // return ResponseVO.ok("执行成功",test); |
| | | return test; |
| | | } |
| | |
| | | |
| | | //如果MD5的对应文件存在则直接返回 |
| | | // Result result = fileService.checkMd5(md5,fileName); |
| | | String substring = fileName.substring(fileName.indexOf(".")+1); |
| | | |
| | | return hweiYunOBSService.initUploadChunk(identifier.concat(ClientUtils.getUserId()), fileName,md5); |
| | | StringBuffer path=new StringBuffer(); |
| | | //识别文件后缀格式,获取对应的文件存储路径 |
| | | String pathFile = CacheConstants.fileFormatMap.get(substring.toUpperCase(Locale.ROOT)); |
| | | if (StringUtils.isEmpty(pathFile)) {//如果为空则上传到默认存储文件夹 |
| | | path.append(CacheConstants.GUANGXI_ACQUIESCE); |
| | | }else{ |
| | | path.append(pathFile); |
| | | } |
| | | String uuid = UUIDUtils.UUID(); |
| | | //将文件重新命名,防止出现重名覆盖 |
| | | String newFilename=uuid.concat(String.valueOf(fileName.lastIndexOf("."))); |
| | | return hweiYunOBSService.initUploadChunk(identifier.concat(ClientUtils.getUserId()),path.append(newFilename).toString(),md5); |
| | | |
| | | } |
| | | |