| | |
| | | String destPath = getDestPath(name); |
| | | String fullPath = config.getResRootPath() + "/" + destPath; |
| | | |
| | | //截取上传华为云的编码 |
| | | File fileRoot = new File(fullPath.substring(0, fullPath.lastIndexOf("/"))); |
| | | |
| | | if (!fileRoot.exists()) { |
| | | fileRoot.mkdirs(); |
| | | } |
| | | |
| | | //压缩 |
| | | FileUtils.copyInputStreamToFile(in, new File(fullPath)); |
| | | |
| | | //华为云编码存入数据库 |
| | | ResFile file = insertFileToDB(name, fullPath, destPath, getFileType(name)); |
| | | |
| | | return new Result(true, "success", |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Result checkMd5(String md5, String fileName) { |
| | | // if(StringUtils.isBlank(md5)){ |
| | | // return Result.FAIL; |
| | | // } |
| | | // |
| | | // |
| | | // Boolean objectExist; |
| | | // objectExist = authOssService.doseObjectExist(resFile.getPath()); |
| | | // |
| | | // if (objectExist) { |
| | | // |
| | | // ResFileDO resFileToDB = new ResFileDO(); |
| | | // BeanUtils.copyProperties(resFile, resFileToDB); |
| | | // resFileToDB.setId(null); |
| | | // TraceUtils.setCreateTrace(resFileToDB); |
| | | // ResFileDO resFileDB = save(resFileToDB); |
| | | // |
| | | // Result result = new Result(true, "fileId", resFileDB.getId(), "path", resFileDB.getPath(),"fileName",fileName, |
| | | // "fileSize",resFileToDB.getSize(),"fileType",resFileToDB.getFileType(),"hit",true); |
| | | // result.setResultCode(201); |
| | | // return result; |
| | | // |
| | | // } |
| | | |
| | | return Result.FAIL; |
| | | } |
| | | } |