| | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | |
| | |
| | | public class OssServiceImpl implements OssService { |
| | | @Override |
| | | public String uploadImages(MultipartFile file) { |
| | | DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | System.out.println("开始上传--" + dtf2.format(LocalDateTime.now())); |
| | | if (file == null) { |
| | | return "上传文件为空"; |
| | | } |
| | |
| | | Date expiration = new Date(System.currentTimeMillis() + (long) 946080000 * 1000); |
| | | String url = ossClient.generatePresignedUrl(bucketName, fileName, expiration).toString(); |
| | | |
| | | System.out.println("上传结束--" + dtf2.format(LocalDateTime.now())); |
| | | return url; |
| | | } catch (Exception e) { |
| | | System.out.println("uploadImages上传图片失败:"); |