本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3URI.getBucket方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3URI.getBucket方法的具体用法?Java AmazonS3URI.getBucket怎么用?Java AmazonS3URI.getBucket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.AmazonS3URI
的用法示例。
在下文中一共展示了AmazonS3URI.getBucket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConf
import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的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: parse
import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
/**
* Parse string representing an AWS S3 URI
*/
protected void parse(String s3UriStr) {
s3uri = new AmazonS3URI(s3UriStr);
bucketName = s3uri.getBucket();
key = s3uri.getKey();
// Parse and set region
String regionStr = s3uri.getRegion();
try {
// if (regionStr == null) regionStr = Config.get().getString(Config.AWS_REGION, DEFAULT_AWS_REGION);
// region = Region.getRegion(Regions.valueOf(regionStr.toUpperCase()));
if (regionStr != null) region = Region.getRegion(Regions.valueOf(regionStr.toUpperCase()));
} catch (Exception e) {
throw new RuntimeException("Cannot parse AWS region '" + regionStr + "'", e);
}
}
示例3: BucketKey
import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
public BucketKey(String inputFilePath, String outputFilePath){
AmazonS3URI srcURI = new AmazonS3URI(inputFilePath);
AmazonS3URI destURI = new AmazonS3URI(outputFilePath);
this.srcBucket = srcURI.getBucket();
this.srcKey = srcURI.getKey();
this.destBucket = destURI.getBucket();
this.destPrefix = destURI.getKey();
}
示例4: submitCopyJobsFromListing
import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
private void submitCopyJobsFromListing(
AmazonS3URI sourceS3Uri,
final AmazonS3URI targetS3Uri,
ListObjectsRequest request,
ObjectListing listing) {
LOG.debug("Found objects to copy {}, for request {}/{}", listing.getObjectSummaries(), request.getBucketName(),
request.getPrefix());
List<S3ObjectSummary> objectSummaries = listing.getObjectSummaries();
for (final S3ObjectSummary s3ObjectSummary : objectSummaries) {
String fileName = StringUtils.removeStart(s3ObjectSummary.getKey(), sourceS3Uri.getKey());
final String targetKey = Strings.nullToEmpty(targetS3Uri.getKey()) + fileName;
LOG.info("copying object from '{}/{}' to '{}/{}'", s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey(),
targetS3Uri.getBucket(), targetKey);
CopyObjectRequest copyObjectRequest = new CopyObjectRequest(s3ObjectSummary.getBucketName(),
s3ObjectSummary.getKey(), targetS3Uri.getBucket(), targetKey);
TransferStateChangeListener stateChangeListener = new TransferStateChangeListener() {
@Override
public void transferStateChanged(Transfer transfer, TransferState state) {
if (state == TransferState.Completed) {
// NOTE: running progress doesn't seem to be reported correctly.
// transfer.getProgress().getBytesTransferred() is always 0. Unsure what is the cause of this at this moment
// so just printing total bytes when completed.
LOG.debug("copied object from '{}/{}' to '{}/{}': {} bytes transferred", s3ObjectSummary.getBucketName(),
s3ObjectSummary.getKey(), targetS3Uri.getBucket(), targetKey,
transfer.getProgress().getTotalBytesToTransfer());
}
}
};
Copy copy = transferManager.copy(copyObjectRequest, srcClient, stateChangeListener);
totalBytesToReplicate += copy.getProgress().getTotalBytesToTransfer();
copyJobs.add(copy);
}
}
示例5: putByteSequence
import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
@Override
public void putByteSequence(ByteSequence byteSequence, Key key, @Nullable MutableObjectMetadata metadata)
throws IOException {
@Nullable String byteSequenceBucket = null;
@Nullable String byteSequenceKey = null;
@Nullable URI byteSequenceURI = byteSequence.getURI();
if (byteSequenceURI != null && "s3".equals(byteSequenceURI.getScheme())) {
byteSequenceBucket = byteSequenceURI.getAuthority();
byteSequenceKey = byteSequenceURI.getPath();
}
if (byteSequenceBucket == null || byteSequenceBucket.isEmpty() || byteSequenceKey == null
|| byteSequenceKey.isEmpty()) {
@Nullable AmazonS3URI amazonS3URI = uriToAmazonS3Uri(byteSequenceURI);
if (amazonS3URI != null) {
byteSequenceBucket = amazonS3URI.getBucket();
byteSequenceKey = amazonS3URI.getKey();
}
}
boolean wroteByteSequence = false;
if (byteSequenceBucket != null && !byteSequenceBucket.isEmpty() && byteSequenceKey != null
&& !byteSequenceKey.isEmpty()) {
// Best case: If the byte sequence originates from S3, simply perform a S3 copy operation
try {
s3Connection.getS3Client().copyObject(
byteSequenceBucket, byteSequenceKey, bucketName, targetPath(key).toString()
);
wroteByteSequence = true;
} catch (AmazonClientException exception) {
log.info(String.format(
"Request for S3 server-side copy from 's3://%s/%s' to '%s' failed. This is not yet a "
+ "problem, will attempt client-side copy instead.",
byteSequenceBucket, byteSequenceKey, createS3Uri(targetPath(key))
), exception);
}
}
if (!wroteByteSequence) {
try (
InputStream inputStream = byteSequence.newInputStream();
OutputStream outputStream
= s3Connection.newBufferedOutputStream(bucketName, targetPath(key).toString())
) {
copy(inputStream, outputStream);
}
}
}
示例6: loadFromTo
import com.amazonaws.services.s3.AmazonS3URI; //导入方法依赖的package包/类
/**
* A method that creates an InputStream on a specific range of the file.
* InputStream classes wrapping order can be reversed.
*
* @param obj target file URI
* @param offset range start position
* @param end range end position
* @return an InputStream object on the specific range of the file.
*/
public InputStream loadFromTo(AmazonS3URI obj, long offset, long end) {
GetObjectRequest rangeObjectRequest = new GetObjectRequest(obj.getBucket(), obj.getKey());
rangeObjectRequest.setRange(offset, end);
S3Object s3Object = client.getAws().getObject(rangeObjectRequest);
PerformanceMonitor.logRequest();
S3ObjectInputStream objectStream = s3Object.getObjectContent();
return new MonitoredInputStream(new BufferedInputStream(objectStream));
}