本文整理汇总了Java中com.amazonaws.services.s3.S3ClientOptions类的典型用法代码示例。如果您正苦于以下问题:Java S3ClientOptions类的具体用法?Java S3ClientOptions怎么用?Java S3ClientOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
S3ClientOptions类属于com.amazonaws.services.s3包,在下文中一共展示了S3ClientOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAmazonS3Client
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
private AmazonS3Client getAmazonS3Client(BackupRestoreContext ctx) throws URISyntaxException {
final String accessKey = ctx.getAccountId();
final String secretKey = ctx.getSecretKey();
String endpoint = getEndpoint(ctx);
LOGGER.info("endpoint: {}", endpoint);
final BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey);
final AmazonS3Client amazonS3Client = new AmazonS3Client(basicAWSCredentials);
amazonS3Client.setEndpoint(endpoint);
if (ctx.usesEmc()) {
final S3ClientOptions options = new S3ClientOptions();
options.setPathStyleAccess(true);
amazonS3Client.setS3ClientOptions(options);
}
return amazonS3Client;
}
示例2: connectToS3
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
private void connectToS3(String accessKey, String secretKey, String endpoint, boolean secure, boolean pathStyle) {
LOG.info("'{}','{}','{}'", accessKey, secretKey, endpoint);
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
ClientConfiguration clientConfiguration = new ClientConfiguration()
.withProtocol(secure ? Protocol.HTTPS : Protocol.HTTP)
.withUserAgentPrefix("s3browser")
.withSignerOverride("S3SignerType");
s3Client = new AmazonS3Client(credentials, clientConfiguration);
s3Client.setS3ClientOptions(S3ClientOptions.builder()
.setPathStyleAccess(pathStyle)
.disableChunkedEncoding()
.build());
s3Client.setEndpoint(endpoint);
}
示例3: start
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
@Override
public void start(Map<String, String> props) throws ConnectException {
readConfig(props);
// Use default credentials provider that looks in Env + Java properties + profile + instance role
AmazonS3 s3Client = new AmazonS3Client();
// If worker config sets explicit endpoint override (e.g. for testing) use that
if (overrideS3Endpoint != "") {
s3Client.setEndpoint(overrideS3Endpoint);
}
if (s3PathStyle) {
s3Client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
}
s3 = new S3Writer(bucket, prefix, s3Client);
// Recover initial assignments
Set<TopicPartition> assignment = context.assignment();
recoverAssignment(assignment);
}
示例4: newStorage
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
@Override
public Storage newStorage(Config config)
{
AmazonS3Client client = new AmazonS3Client(
buildCredentialsProvider(config),
buildClientConfiguration(config));
if (config.has("endpoint")) {
client.setEndpoint(config.get("endpoint", String.class));
}
if (config.has("path-style-access")) {
client.setS3ClientOptions(
S3ClientOptions.builder().setPathStyleAccess(
config.get("path-style-access", Boolean.class, false)
).build());
}
String bucket = config.get("bucket", String.class);
return new S3Storage(client, bucket);
}
示例5: buildS3Client
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
/**
* @return S3 client
*/
private AmazonS3 buildS3Client() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
ClientConfiguration clientConfiguration = new ClientConfiguration()
.withProtocol(useHttp ? Protocol.HTTP : Protocol.HTTPS)
.withUserAgent("s3pt")
.withGzip(useGzip)
.withTcpKeepAlive(useKeepAlive);
if (signerOverride != null) {
String signer = signerOverride.endsWith("Type")
? signerOverride
: signerOverride + "Type";
clientConfiguration.setSignerOverride(signer);
}
AmazonS3 s3Client = new AmazonS3Client(credentials, clientConfiguration);
s3Client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(usePathStyleAccess).disableChunkedEncoding().build());
s3Client.setEndpoint(endpointUrl);
return s3Client;
}
示例6: configureClient
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
static AmazonS3Client configureClient(AmazonS3Client s3Client) {
if (System.getProperty(S3_REGION) != null) {
String region = System.getProperty(S3_REGION);
Log.debug("S3 region specified: ", region);
s3Client.setRegion(RegionUtils.getRegion(region));
}
// Region overrides end-point settings
if (System.getProperty(S3_END_POINT) != null) {
String endPoint = System.getProperty(S3_END_POINT);
Log.debug("S3 endpoint specified: ", endPoint);
s3Client.setEndpoint(endPoint);
}
if (System.getProperty(S3_ENABLE_PATH_STYLE) != null && Boolean.valueOf(System.getProperty(S3_ENABLE_PATH_STYLE))) {
Log.debug("S3 path style access enabled");
S3ClientOptions sco = new S3ClientOptions();
sco.setPathStyleAccess(true);
s3Client.setS3ClientOptions(sco);
}
return s3Client;
}
示例7: setUp
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY,
SECRET_KEY);
final ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setPreemptiveBasicProxyAuth(true);
final S3ClientOptions options = new S3ClientOptions();
options.setPathStyleAccess(true);
final AmazonS3Client client = new AmazonS3Client(credentials,
clientConfiguration);
client.setS3ClientOptions(options);
client.setEndpoint("http://localhost:8080");
_repo = new AmazonS3Repository(client);
}
示例8: testDoubleDots
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
public void testDoubleDots() throws Exception {
String filename = System.getProperty("user.home")+"/aws.properties";
PropertiesCredentials credentials = new PropertiesCredentials(new File(filename));
AmazonS3Client client = new AmazonS3Client(credentials);
client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
client.setRegion(Region.getRegion(Regions.EU_WEST_1));
testPrefix(client,"",6);
Collections.sort(prefixTestResults);
for (String s : prefixTestResults) {
System.out.println(s);
}
}
示例9: setAmazonS3ConnectionEndpoint
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
private void setAmazonS3ConnectionEndpoint() {
S3ClientOptions.Builder clientOptionsBuilder = S3ClientOptions.builder();
Optional<URI> endpoint = s3ConnectionProperties.getEndpoint();
if (endpoint.isPresent()) {
amazonS3Client.setEndpoint(endpoint.get().toString());
clientOptionsBuilder.setPathStyleAccess(true);
}
amazonS3Client.setS3ClientOptions(clientOptionsBuilder.build());
}
示例10: S3DiscoveryCallback
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
@Inject
public S3DiscoveryCallback(final AmazonS3 s3,
final Configuration configuration,
final PluginExecutorService pluginExecutorService) {
this.s3 = s3;
this.s3.setEndpoint(configuration.getEndpoint());
this.s3.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(configuration.withPathStyleAccess()));
this.configuration = configuration;
this.pluginExecutorService = pluginExecutorService;
this.bucketName = configuration.getBucketName();
}
示例11: s3Ninja
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
@Bean
@Profile("dev")
public AmazonS3Client s3Ninja() {
AWSCredentials credentials = new BasicAWSCredentials(
"AKIAIOSFODNN7EXAMPLE",
"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");
AmazonS3Client newClient = new AmazonS3Client(credentials,
new ClientConfiguration());
newClient.setS3ClientOptions(new S3ClientOptions()
.withPathStyleAccess(true));
newClient.setEndpoint("http://localhost:9444/s3");
return newClient;
}
示例12: s3Amazon
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
@Bean
@Profile("prod")
public AmazonS3Client s3Amazon() {
AWSCredentials credentials = new BasicAWSCredentials(
"AKIAIOSFODNN7EXAMPLE",
"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");
AmazonS3Client newClient = new AmazonS3Client(credentials,
new ClientConfiguration());
newClient.setS3ClientOptions(new S3ClientOptions()
.withPathStyleAccess(true));
return newClient;
}
示例13: setUp
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
s3mock = System.getProperty("s3mock");
s3mock = s3mock != null ? s3mock : "http://localhost:9444/s3";
client = new AmazonS3Client(new BasicAWSCredentials("AKIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"));
client.setEndpoint(s3mock);
client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
}
示例14: testCustomRegionAndPathStyleAccess
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
@Test
public void testCustomRegionAndPathStyleAccess()
throws Exception
{
Config config = newConfig();
config.set("path_style_access", true);
config.set("_command", BUCKET + "/" + KEY);
when(taskRequest.getConfig()).thenReturn(config);
when(s3Secrets.getSecretOptional("region")).thenReturn(Optional.of(REGION));
when(s3Client.getObjectMetadata(objectMetadataRequestCaptor.capture())).thenThrow(NOT_FOUND_EXCEPTION);
Operator operator = factory.newOperator(newContext(projectPath, taskRequest));
try {
operator.run();
fail();
}
catch (TaskExecutionException ignore) {
}
verify(s3Client).setS3ClientOptions(s3ClientOptionsCaptor.capture());
S3ClientOptions s3ClientOptions = s3ClientOptionsCaptor.getValue();
assertThat(s3ClientOptions.isPathStyleAccess(), is(true));
verify(s3Client).setRegion(RegionUtils.getRegion(REGION));
}
示例15: getS3Client
import com.amazonaws.services.s3.S3ClientOptions; //导入依赖的package包/类
public static ViPRS3Client getS3Client(String S3_ACCESS_KEY_ID,
String S3_SECRET_KEY, String S3_ENDPOINT, String S3_ViPR_NAMESPACE) {
BasicAWSCredentials creds = new BasicAWSCredentials(S3_ACCESS_KEY_ID,
S3_SECRET_KEY);
S3ClientOptions opt = new S3ClientOptions();
opt.setPathStyleAccess(true);
ViPRS3Client client = new ViPRS3Client(S3_ENDPOINT, creds);
client.setS3ClientOptions(opt);
if (S3_ViPR_NAMESPACE != null) {
client.setNamespace(S3_ViPR_NAMESPACE);
}
return client;
}