use of software.amazon.awssdk.services.s3.model.Progress in project aws-doc-sdk-examples by awsdocs.
the class ListMultipartUploads method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <bucketName> \n\n" + "Where:\n" + " bucketName - the name of the Amazon S3 bucket where an in-progress multipart upload is occurring.\n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String bucketName = args[0];
Region region = Region.US_WEST_2;
S3Client s3 = S3Client.builder().region(region).build();
listUploads(s3, bucketName);
s3.close();
}
use of software.amazon.awssdk.services.s3.model.Progress in project djl by deepjavalibrary.
the class S3Repository method download.
/**
* {@inheritDoc}
*/
@Override
protected void download(Path tmp, URI baseUri, Artifact.Item item, Progress progress) throws IOException {
String key = item.getUri();
logger.debug("Downloading artifact from: s3://{}/{} ...", bucket, key);
GetObjectRequest req = GetObjectRequest.builder().bucket(bucket).key(key).build();
try (ResponseInputStream<GetObjectResponse> is = client.getObject(req)) {
save(is, tmp, item, progress);
}
}
use of software.amazon.awssdk.services.s3.model.Progress in project datarouter by hotpads.
the class BaseDatarouterS3Client method handleTransfer.
private void handleTransfer(Transfer transfer, Runnable heartbeat) {
TransferProgress progress = transfer.getProgress();
long totalBytesToTransfer = progress.getTotalBytesToTransfer();
while (!transfer.isDone()) {
try {
heartbeat.run();
} catch (Exception e) {
logger.error("couldn't heartbeat", e);
}
logger.warn("{} / {} pct={} bytesTransferred={} totalBytesToTransfer={}", ByteUnitTool.byteCountToDisplaySize(progress.getBytesTransferred()), ByteUnitTool.byteCountToDisplaySize(totalBytesToTransfer), NumberFormatter.format(progress.getPercentTransferred(), 2), progress.getBytesTransferred(), totalBytesToTransfer);
ThreadTool.sleepUnchecked(1000L);
}
}
use of software.amazon.awssdk.services.s3.model.Progress in project aws-doc-sdk-examples by awsdocs.
the class ListMultipartUploads method listUploads.
// snippet-start:[s3.java2.list_multi_uploads.main]
public static void listUploads(S3Client s3, String bucketName) {
try {
ListMultipartUploadsRequest listMultipartUploadsRequest = ListMultipartUploadsRequest.builder().bucket(bucketName).build();
ListMultipartUploadsResponse response = s3.listMultipartUploads(listMultipartUploadsRequest);
List<MultipartUpload> uploads = response.uploads();
for (MultipartUpload upload : uploads) {
System.out.println("Upload in progress: Key = \"" + upload.key() + "\", id = " + upload.uploadId());
}
} catch (S3Exception e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.s3.model.Progress in project aws-sdk-java-v2 by aws.
the class UploadMultiplePartTestBase method uploadMultiplePart_abort.
@Test
public void uploadMultiplePart_abort() throws Exception {
String key = "uploadMultiplePart_abort";
// 1. Initiate multipartUpload request
String uploadId = initiateMultipartUpload(key);
int partCount = 3;
// 2. Upload each part
List<String> contentsToUpload = new ArrayList<>();
List<UploadPartResponse> uploadPartResponses = uploadParts(key, uploadId, partCount, contentsToUpload);
// 3. abort the multipart upload
AbortMultipartUploadResponse abortMultipartUploadResponse = abortMultipartUploadResponseCallable(AbortMultipartUploadRequest.builder().bucket(BUCKET).key(key).uploadId(uploadId).build()).call();
// Verify no in-progress multipart uploads
ListMultipartUploadsResponse listMultipartUploadsResponse = listMultipartUploads(BUCKET).call();
List<MultipartUpload> uploads = listMultipartUploadsResponse.uploads();
assertThat(uploads).isEmpty();
}
Aggregations