package com.example.jz.service.impl; import com.example.jz.config.MinIOConfig; import com.example.jz.service.MinIOService; import io.minio.GetPresignedObjectUrlArgs; import io.minio.MinioClient; import io.minio.errors.*; import io.minio.http.Method; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.concurrent.TimeUnit; @Service public class MinIOServiceImpl implements MinIOService { @Autowired MinioClient minioClient; @Autowired MinIOConfig minIOConfig; @Override public String getPreviewFileUrl(String fileName){ String res = null; try { res = minioClient.presignedGetObject(minIOConfig.getBucketName(), fileName); } catch (ErrorResponseException e) { throw new RuntimeException(e); } catch (InsufficientDataException e) { throw new RuntimeException(e); } catch (InternalException e) { throw new RuntimeException(e); } catch (InvalidBucketNameException e) { throw new RuntimeException(e); } catch (InvalidExpiresRangeException e) { throw new RuntimeException(e); } catch (InvalidKeyException e) { throw new RuntimeException(e); } catch (InvalidResponseException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (ServerException e) { throw new RuntimeException(e); } catch (XmlParserException e) { throw new RuntimeException(e); } return res; } }