Skip to content
Snippets Groups Projects
Commit aa1f2aac authored by ivan's avatar ivan
Browse files

[s3] added setProtocol for s3Client

parent de4b39d4
No related branches found
No related tags found
No related merge requests found
......@@ -18,3 +18,6 @@ s3.sse=false
# activating the SSE-C client side encryption if used
#s3.ssec=U2CccCI40he2mZtg2aCEzofP7nQsfy4nP14VSYu6bFA=
# set the protocol to use for the Client, default is HTTP
s3.protocol=HTTPS
......@@ -43,6 +43,7 @@ import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.Protocol;
import com.amazonaws.services.s3.model.DeleteObjectRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3ObjectSummary;
......@@ -148,6 +149,7 @@ public class S3Client extends DB {
String endPoint = null;
String region = null;
String maxErrorRetry = null;
String protocol = null;
BasicAWSCredentials s3Credentials;
ClientConfiguration clientConfig;
if (s3Client != null) {
......@@ -183,6 +185,10 @@ public class S3Client extends DB {
if (maxErrorRetry == null){
maxErrorRetry = propsCL.getProperty("s3.maxErrorRetry", "15");
}
protocol = props.getProperty("s3.protocol");
if (protocol == null){
protocol = propsCL.getProperty("s3.protocol", "HTTP");
}
sse = props.getProperty("s3.sse");
if (sse == null){
sse = propsCL.getProperty("s3.sse", "false");
......@@ -202,6 +208,9 @@ public class S3Client extends DB {
s3Credentials = new BasicAWSCredentials(accessKeyId, secretKey);
clientConfig = new ClientConfiguration();
clientConfig.setMaxErrorRetry(Integer.parseInt(maxErrorRetry));
if(protocol.equals("HTTPS")) {
clientConfig.setProtocol(Protocol.HTTPS);
}
s3Client = new AmazonS3Client(s3Credentials, clientConfig);
s3Client.setRegion(Region.getRegion(Regions.fromName(region)));
s3Client.setEndpoint(endPoint);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment