/** * @see java.lang.Object#toString() */ public String toString() { return "S3Object [key=" + getKey() + ",bucket=" + (bucketName == null ? "<Unknown>" : bucketName) + "]"; }
String getKey() { return s3obj.getKey(); }
for (S3ObjectSummary objectSummary : current.getObjectSummaries()) { S3Object object = s3.getObject(new GetObjectRequest(bucketName, objectSummary.getKey())); System.out.println(object.getKey()); object.close(); }
/*** * Download a S3 object to local directory * * @param s3ObjectSummary S3 object summary for the object to download * @param targetDirectory Local target directory to download the object to * @throws IOException If any errors were encountered in downloading the object */ public void downloadS3Object(S3ObjectSummary s3ObjectSummary, String targetDirectory) throws IOException { final AmazonS3 amazonS3 = getS3Client(); final GetObjectRequest getObjectRequest = new GetObjectRequest( s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey()); final S3Object s3Object = amazonS3.getObject(getObjectRequest); final String targetFile = StringUtils.removeEnd(targetDirectory, File.separator) + File.separator + s3Object.getKey(); FileUtils.copyInputStreamToFile(s3Object.getObjectContent(), new File(targetFile)); LOGGER.info("S3 object downloaded to file: " + targetFile); }
throw ace; } else { LOG.info("Retry the download of object " + s3Object.getKey() + " (bucket " + s3Object.getBucketName() + ")", ace); hasRetried = true;
throw new SecurityException("Instruction file not found for S3 object with bucket name: " + retrieved.getBucketName() + ", key: " + retrieved.getKey()); "Unable to detect encryption information for object '%s' in bucket '%s'. " + "Returning object without decryption.", retrieved.getKey(), retrieved.getBucketName()));
throw ace; } else { LOG.info("Retry the download of object " + s3Object.getKey() + " (bucket " + s3Object.getBucketName() + ")", ace); hasRetried = true;
/** * Creates and returns a {@link PutObjectRequest} for the instruction file * with the specified suffix. */ public PutObjectRequest createPutObjectRequest(S3Object s3Object) { if (!s3Object.getBucketName().equals(s3ObjectId.getBucket()) || !s3Object.getKey().equals(s3ObjectId.getKey())) { throw new IllegalArgumentException("s3Object passed inconsistent with the instruction file being created"); } InstructionFileId ifid= s3ObjectId.instructionFileId(suffix); // ObjectMetadata metadata = s3Object.getObjectMetadata(); return new PutObjectRequest(ifid.getBucket(), ifid.getKey(), redirectLocation) .withAccessControlList(accessControlList) .withCannedAcl(cannedAcl) // .withFile(file) // .withInputStream(inputStream) // don't want the metadata for the new instruction file // .withMetadata(metadata == null ? null : metadata.clone()) .withStorageClass(storageClass) .withGeneralProgressListener(getGeneralProgressListener()) .withRequestMetricCollector(getRequestMetricCollector()) ; } }
/** * @see java.lang.Object#toString() */ public String toString() { return "S3Object [key=" + getKey() + ",bucket=" + (bucketName == null ? "<Unknown>" : bucketName) + "]"; }
/** * The key under which this object was stored in Amazon S3. * * @return The key under which this object was stored in Amazon S3. */ @Override public String getKey() { return s3Object.getKey(); }
String getKey() { return s3obj.getKey(); }
String.format( "Necessary encryption info not found in the headers of file '%s' in bucket '%s'", object.getKey(), object.getBucketName())); String.format("Unable to retrieve the encryption materials that originally " + "encrypted file '%s' in bucket '%s'.", object.getKey(), object.getBucketName()));
/** * Creates and returns a {@link PutObjectRequest} for the instruction file * with the specified suffix. */ public PutObjectRequest createPutObjectRequest(S3Object s3Object) { if (!s3Object.getBucketName().equals(s3ObjectId.getBucket()) || !s3Object.getKey().equals(s3ObjectId.getKey())) { throw new IllegalArgumentException("s3Object passed inconsistent with the instruction file being created"); } InstructionFileId ifid= s3ObjectId.instructionFileId(suffix); // ObjectMetadata metadata = s3Object.getObjectMetadata(); return new PutObjectRequest(ifid.getBucket(), ifid.getKey(), redirectLocation) .withAccessControlList(accessControlList) .withCannedAcl(cannedAcl) // .withFile(file) // .withInputStream(inputStream) // don't want the metadata for the new instruction file // .withMetadata(metadata == null ? null : metadata.clone()) .withStorageClass(storageClass) .withGeneralProgressListener(getGeneralProgressListener()) .withRequestMetricCollector(getRequestMetricCollector()) ; } }
/** * @see java.lang.Object#toString() */ public String toString() { return "S3Object [key=" + getKey() + ",bucket=" + (bucketName == null ? "<Unknown>" : bucketName) + "]"; }
/** * The key under which this object was stored in Amazon S3. * * @return The key under which this object was stored in Amazon S3. */ @Override public String getKey() { return s3Object.getKey(); }
@Override public String toString() { return "FileSystemWritableConfiguration{objectKey=" + s3Object.getKey() + ", version='" + version + "'}"; }
throw new SecurityException("Instruction file not found for S3 object with bucket name: " + retrieved.getBucketName() + ", key: " + retrieved.getKey()); "Unable to detect encryption information for object '%s' in bucket '%s'. " + "Returning object without decryption.", retrieved.getKey(), retrieved.getBucketName()));
throw ace; } else { log.info("Retry the download of object " + s3Object.getKey() + " (bucket " + s3Object.getBucketName() + ")", ace); hasRetried = true;
private void closeObject(S3Object object) throws StorageException { try { object.close(); } catch (IOException e) { throw new StorageException( "Error closing connection to " + object.getKey() + ": " + e.getMessage(), e); } }