| | |
| | | @Override
|
| | | public String uploadFile(MultipartFile file) throws Exception
|
| | | {
|
| | | InputStream inputStream = null;
|
| | | try
|
| | | {
|
| | | String fileName = FileUploadUtils.extractFilename(file);
|
| | | InputStream inputStream = file.getInputStream();
|
| | | inputStream = file.getInputStream();
|
| | | PutObjectArgs args = PutObjectArgs.builder()
|
| | | .bucket(minioConfig.getBucketName())
|
| | | .object(fileName)
|
| | |
| | | .contentType(file.getContentType())
|
| | | .build();
|
| | | client.putObject(args);
|
| | | IoUtils.closeQuietly(inputStream);
|
| | | return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | throw new RuntimeException("Minio Failed to upload file", e);
|
| | | }
|
| | | finally
|
| | | {
|
| | | IoUtils.closeQuietly(inputStream);
|
| | | }
|
| | | }
|
| | | }
|