NIFI-1225: When ENDPOINT_OVERRIDE is set, use PathStyleAccess

Reviewed by Mark Payne <markap14@hotmail.com>
This commit is contained in:
Tony Kurc 2015-12-01 20:06:43 -05:00
parent fcc032c7fd
commit 8f92ac9931
1 changed files with 12 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.processor.ProcessContext;
@ -30,6 +31,7 @@ import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.AccessControlList;
import com.amazonaws.services.s3.model.CanonicalGrantee;
import com.amazonaws.services.s3.model.EmailAddressGrantee;
@ -103,7 +105,16 @@ public abstract class AbstractS3Processor extends AbstractAWSProcessor<AmazonS3C
@Override
protected AmazonS3Client createClient(final ProcessContext context, final AWSCredentials credentials, final ClientConfiguration config) {
return new AmazonS3Client(credentials, config);
final AmazonS3Client s3 = new AmazonS3Client(credentials, config);
// if ENDPOINT_OVERRIDE is set, use PathStyleAccess
if(StringUtils.trimToEmpty(context.getProperty(ENDPOINT_OVERRIDE).getValue()).isEmpty() == false){
final S3ClientOptions s3Options = new S3ClientOptions();
s3Options.setPathStyleAccess(true);
s3.setS3ClientOptions(s3Options);
}
return s3;
}
protected Grantee createGrantee(final String value) {