|
|
|
@ -13,6 +13,8 @@ import com.fr.io.context.info.RepositoryProfile;
|
|
|
|
|
import com.fr.io.repository.ResourceRepository; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
import static com.fanruan.fs.s3.repository.core.S3ResourceRepository.HTTP; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author richie |
|
|
|
|
* @version 10.0 |
|
|
|
@ -42,16 +44,19 @@ public class S3RepositoryFactory extends ConfigRepositoryFactory<S3Config> {
|
|
|
|
|
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getPassword()); |
|
|
|
|
AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard() |
|
|
|
|
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion())) |
|
|
|
|
.withCredentials(new AWSStaticCredentialsProvider(credentials)); |
|
|
|
|
.withCredentials(new AWSStaticCredentialsProvider(credentials)).disableChunkedEncoding(); |
|
|
|
|
if (config.isEnablePathStyleAccess()) { |
|
|
|
|
amazonS3ClientBuilder = amazonS3ClientBuilder.enablePathStyleAccess(); |
|
|
|
|
} |
|
|
|
|
ClientConfiguration clientConfiguration = new ClientConfiguration(); |
|
|
|
|
if (StringUtils.isNotEmpty(config.getSignerOverride())) { |
|
|
|
|
ClientConfiguration clientConfiguration = new ClientConfiguration(); |
|
|
|
|
clientConfiguration.setSignerOverride(config.getSignerOverride()); |
|
|
|
|
} |
|
|
|
|
LogKit.debug("[S3] endpoint is {}", config.getEndPoint()); |
|
|
|
|
if (config.getEndPoint().startsWith(HTTP)) { |
|
|
|
|
clientConfiguration.setProtocol(Protocol.HTTP); |
|
|
|
|
amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration); |
|
|
|
|
} |
|
|
|
|
amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration); |
|
|
|
|
AmazonS3 s3 = amazonS3ClientBuilder.build(); |
|
|
|
|
s3.listObjects(config.getBucket()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|