本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3Client.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3Client.getObject方法的具体用法?Java AmazonS3Client.getObject怎么用?Java AmazonS3Client.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.AmazonS3Client
的用法示例。
在下文中一共展示了AmazonS3Client.getObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConf
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
@Override
public void setConf(AbstractConfig config) {
this.config = (GeoIpOperationConfig) config;
AmazonS3Client client = this.s3Factory.newInstance();
AmazonS3URI uri = new AmazonS3URI(this.config.getGeoLiteDb());
GetObjectRequest req = new GetObjectRequest(uri.getBucket(), uri.getKey());
S3Object obj = client.getObject(req);
try {
this.databaseReader =
new DatabaseReader.Builder(obj.getObjectContent()).withCache(new CHMCache()).build();
} catch (IOException e) {
throw new ConfigurationException("Unable to read " + this.config.getGeoLiteDb(), e);
}
}
示例2: load
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
public static BenderConfig load(AmazonS3ClientFactory s3ClientFactory, AmazonS3URI s3Uri) {
AmazonS3Client s3 = s3ClientFactory.newInstance();
S3Object s3object = s3.getObject(s3Uri.getBucket(), s3Uri.getKey());
StringWriter writer = new StringWriter();
try {
IOUtils.copy(s3object.getObjectContent(), writer, "UTF-8");
} catch (IOException e) {
throw new ConfigurationException("Unable to read file from s3", e);
}
BenderConfig config = load(s3Uri.getKey().toString(), writer.toString());
config.setConfigFile(s3Uri.getURI().toString());
return config;
}
示例3: downloadSchema
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
@Override
public String downloadSchema(BackupRestoreContext ctx) throws Exception {
final String nodeId = ctx.getNodeId();
final AmazonS3Client amazonS3Client = getAmazonS3Client(ctx);
final String key = getPrefixKey(ctx) + "/" + nodeId + "/" + StorageUtil.SCHEMA_FILE;
S3Object object = amazonS3Client.getObject(
new GetObjectRequest(getBucketName(ctx), key));
InputStream objectData = object.getObjectContent();
String schema = IOUtils.toString(objectData, "UTF-8");
objectData.close();
return schema;
}
示例4: getObject
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
@Override
public S3Object getObject(String bucket, String key) throws Exception
{
RefCountedClient holder = client.get();
AmazonS3Client amazonS3Client = holder.useClient();
try
{
return amazonS3Client.getObject(bucket, key);
}
finally
{
holder.release();
}
}