| | |
| | | package com.oying.service.impl; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.obs.services.model.AccessControlList; |
| | | import com.obs.services.model.PutObjectResult; |
| | |
| | | FileUtil.checkSize(fileProperties.getMaxSize(), file.getSize()); |
| | | String suffix = FileUtil.getExtensionName(file.getOriginalFilename()); |
| | | String type = FileUtil.getFileType(suffix); |
| | | String reaName = System.currentTimeMillis() + "." + suffix; |
| | | String reaName = IdUtil.getSnowflake(1, 1).nextId() + "." + suffix; |
| | | String objectKey = type + "/" + reaName; |
| | | PutObjectResult result = ObsUtils.putObject(properties, FileUtil.toFile(file), objectKey, AccessControlList.REST_CANNED_PUBLIC_READ); |
| | | if (ObjectUtil.isNull(result)) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteById(String path) { |
| | | BucketStorage storage = bucketStorageMapper.findByPath(path); |
| | | ObsUtils.deleteObject(properties, storage.getPath()); |
| | | bucketStorageMapper.deleteById(storage.getBucketId()); |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<BucketStorage> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (BucketStorage bucketStorage : all) { |