rain
2024-08-21 2db1aa88e8ab53096a936163d686b90d8e056a99
src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java
@@ -1,5 +1,6 @@
package com.dji.sample.component.oss.service.impl;
import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.component.oss.model.OssConfiguration;
import com.dji.sample.component.oss.model.enums.OssTypeEnum;
import com.dji.sample.component.oss.service.IOssService;
@@ -38,7 +39,7 @@
    @Override
    public CredentialsDTO getCredentials() {
        try {
            AssumeRoleProvider provider = new AssumeRoleProvider(OssConfiguration.endpoint, OssConfiguration.accessKey,
            AssumeRoleProvider provider = new AssumeRoleProvider(OssConfiguration.externalEndpoint, OssConfiguration.accessKey,
                    OssConfiguration.secretKey, Math.toIntExact(OssConfiguration.expire),
                    null, OssConfiguration.region, null, null, null, null);
            return new CredentialsDTO(provider.fetch(), OssConfiguration.expire);
@@ -91,10 +92,10 @@
    }
    @Override
    public void putObject(String bucket, String objectKey, InputStream input) {
    public String putObject(String bucket, String objectKey, InputStream input) {
        try {
            client.statObject(StatObjectArgs.builder().bucket(bucket).object(objectKey).build());
            throw new RuntimeException("文件名已存在");
            return "航线名重复";
        } catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
            log.info("文件不存在,开始上传。");
            try {
@@ -106,6 +107,7 @@
                ex.printStackTrace();
            }
        }
        return null;
    }
    public void createClient() {