| | |
| | | import com.obs.services.ObsClient; |
| | | import com.obs.services.exception.ObsException; |
| | | import com.obs.services.model.*; |
| | | 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.service.ICacheService; |
| | |
| | | List<FileMeta> files = new ArrayList<FileMeta>(2); |
| | | FileMeta fileMeta = null; |
| | | try { |
| | | String destPath = getDestPath(objectKey); |
| | | System.out.println(objectKey); |
| | | // String destPath = getDestPath(objectKey); |
| | | String bucketName = hweiOBSConfig.getBucketName(); |
| | | obsClient = hweiOBSConfig.getInstance(); |
| | | |
| | |
| | | } |
| | | InputStream inputStream = uploadFile.getInputStream(); |
| | | long available = inputStream.available(); |
| | | PutObjectRequest request = new PutObjectRequest(bucketName,destPath,inputStream); |
| | | PutObjectRequest request = new PutObjectRequest(bucketName,objectKey,inputStream); |
| | | ObjectMetadata objectMetadata = new ObjectMetadata(); |
| | | objectMetadata.setContentLength(available); |
| | | request.setMetadata(objectMetadata); |
| | |
| | | |
| | | @Override |
| | | public Result initUploadChunk(String uniqueId, String fileName, String md5) { |
| | | String path = getDestPath(fileName); |
| | | String key = chopPath(path); |
| | | String key = chopPath(fileName); |
| | | |
| | | //清缓存 |
| | | cache.template().delete(uniqueId + ClientUtils.getUserId()); |
| | |
| | | |
| | | //为配合分片上传,后台先新建文件记录 |
| | | |
| | | ResFile file = newFileToDB(fileName, path, getFileType(fileName), 0l, md5); |
| | | ResFile file = newFileToDB(fileName, fileName, getFileType(fileName), 0l, md5); |
| | | |
| | | //添加到缓存 |
| | | cache.template().opsForHash().put(uniqueId + ClientUtils.getUserId(), "uploadId", uploadId); |
| | | cache.template().opsForHash().put(uniqueId + ClientUtils.getUserId(), "key", key); |
| | | cache.template().opsForHash().put(uniqueId + ClientUtils.getUserId(), "path", path); |
| | | cache.template().opsForHash().put(uniqueId + ClientUtils.getUserId(), "path", fileName); |
| | | cache.template().opsForHash().put(uniqueId + ClientUtils.getUserId(), "fileId", file.getFileId()); |
| | | |
| | | //防止产生过多缓存垃圾 |