| | |
| | | import com.sandu.common.file.IFileUpload; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.imageio.ImageIO; |
| | |
| | | * @date 2020/12/17 15:31 |
| | | */ |
| | | @Slf4j |
| | | @AllArgsConstructor |
| | | @Component |
| | | public class AliOssFileServiceImpl implements IFileUpload { |
| | | |
| | | private final String endPoint; |
| | | private final String keyId; |
| | | private final String keySecret; |
| | | private final String bucketName; |
| | | private final String host; |
| | | private final String endPoint="oss-cn-shanghai.aliyuncs.com"; |
| | | private final String keyId="LTAI5tPdpt5wvJyLipRijFSP"; |
| | | private final String keySecret="1ahYfCKd0yTddsUnuDLQzI23MLh4VQ"; |
| | | private final String bucketName= "ximonsmart"; |
| | | private String host; |
| | | |
| | | @Override |
| | | public FileUploadDto uploadFile(MultipartFile multipartFile) { |
| | |
| | | long size = multipartFile.getSize(); |
| | | String suffix = FileUtil.getSuffix(originalFilename); |
| | | String dayStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")); |
| | | String fileName = dayStr + UUID.fastUUID().toString() + "." + suffix; |
| | | String fileName = dayStr + UUID.fastUUID()+ "." + suffix; |
| | | |
| | | FileUploadDto uploadDto = new FileUploadDto(); |
| | | OSS ossClient = new OSSClientBuilder().build(endPoint, keyId, keySecret); |
| | |
| | | uploadDto.setHeight(img.getHeight()); |
| | | } |
| | | } |
| | | |
| | | return uploadDto; |
| | | } |
| | | } |