当前位置: 首页>>代码示例>>Java>>正文


Java S3ClientOptions类代码示例

本文整理汇总了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;
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:19,代码来源:S3StorageDriver.java

示例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);
}
 
开发者ID:jenshadlich,项目名称:s3browser,代码行数:17,代码来源:BrowseUI.java

示例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);
}
 
开发者ID:DeviantArt,项目名称:kafka-connect-s3,代码行数:23,代码来源:S3SinkTask.java

示例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);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:22,代码来源:S3StorageFactory.java

示例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;
}
 
开发者ID:jenshadlich,项目名称:S3-Performance-Test,代码行数:26,代码来源:S3PerformanceTest.java

示例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;
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:21,代码来源:PersistS3.java

示例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);
}
 
开发者ID:datacleaner,项目名称:extension_amazon_s3_repository,代码行数:21,代码来源:AmazonS3RepositoryTest.java

示例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);
    }

}
 
开发者ID:michaeltandy,项目名称:s3test,代码行数:17,代码来源:TestKeyNamesS3Rejects.java

示例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());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:S3Client.java

示例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();
}
 
开发者ID:hivemq,项目名称:s3-cluster-discovery-plugin,代码行数:12,代码来源:S3DiscoveryCallback.java

示例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;

}
 
开发者ID:nailtonvieira,项目名称:pswot-cloud-java-spring-webapp,代码行数:16,代码来源:AmazonConfiguration.java

示例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;

}
 
开发者ID:nailtonvieira,项目名称:pswot-cloud-java-spring-webapp,代码行数:15,代码来源:AmazonConfiguration.java

示例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));
}
 
开发者ID:MeteoGroup,项目名称:s3mock,代码行数:9,代码来源:S3MockTest.java

示例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));
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:29,代码来源:S3WaitOperatorFactoryTest.java

示例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;
}
 
开发者ID:thecodeteam,项目名称:VStriker,代码行数:16,代码来源:s3api.java


注:本文中的com.amazonaws.services.s3.S3ClientOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。