return download(getObjectRequest, file, 0);
private Transfer download(Message<?> requestMessage) { Object payload = requestMessage.getPayload(); Assert.state(payload instanceof File, "For the 'DOWNLOAD' operation the 'payload' must be of " + "'java.io.File' type, but gotten: [" + payload.getClass() + ']'); File targetFile = (File) payload; String bucket = obtainBucket(requestMessage); String key = null; if (this.keyExpression != null) { key = this.keyExpression.getValue(this.evaluationContext, requestMessage, String.class); } else { key = targetFile.getName(); } Assert.state(key != null, "The 'keyExpression' must not be null for non-File payloads and can't evaluate to null. " + "Root object is: " + requestMessage); if (targetFile.isDirectory()) { return this.transferManager.downloadDirectory(bucket, key, targetFile); } else { if (this.s3ProgressListener != null) { return this.transferManager.download(new GetObjectRequest(bucket, key), targetFile, this.s3ProgressListener); } else { return this.transferManager.download(bucket, key, targetFile); } } }
return download(bucket, key, file, 0);
private Transfer download(Message<?> requestMessage) { Object payload = requestMessage.getPayload(); Assert.state(payload instanceof File, () -> "For the 'DOWNLOAD' operation the 'payload' must be of " + "'java.io.File' type, but gotten: [" + payload.getClass() + ']'); File targetFile = (File) payload; String bucket = obtainBucket(requestMessage); String key = null; if (this.keyExpression != null) { key = this.keyExpression.getValue(this.evaluationContext, requestMessage, String.class); } else { key = targetFile.getName(); } Assert.state(key != null, () -> "The 'keyExpression' must not be null for non-File payloads and can't evaluate to null. " + "Root object is: " + requestMessage); if (targetFile.isDirectory()) { return this.transferManager.downloadDirectory(bucket, key, targetFile); } else { if (this.s3ProgressListener != null) { return this.transferManager.download(new GetObjectRequest(bucket, key), targetFile, this.s3ProgressListener); } else { return this.transferManager.download(bucket, key, targetFile); } } }
return download(new GetObjectRequest(bucket, key), file, timeoutMillis);
@Override public Void invoke(File localFile, VirtualChannel channel) throws IOException, InterruptedException { TransferManager mgr = TransferManagerBuilder.standard() .withS3Client(AWSClientFactory.create(this.amazonS3ClientOptions.createAmazonS3ClientBuilder(), this.envVars)) .build(); if (this.path == null || this.path.isEmpty() || this.path.endsWith("/")) { final MultipleFileDownload fileDownload = mgr.downloadDirectory(this.bucket, this.path, localFile); fileDownload.waitForCompletion(); RemoteDownloader.this.taskListener.getLogger().println("Finished: " + fileDownload.getDescription()); return null; } else { final Download download = mgr.download(this.bucket, this.path, localFile); download.addProgressListener((ProgressListener) progressEvent -> { if (progressEvent.getEventType() == ProgressEventType.TRANSFER_COMPLETED_EVENT) { RemoteDownloader.this.taskListener.getLogger().println("Finished: " + download.getDescription()); } }); download.waitForCompletion(); return null; } }
private static void downloadFile(ParameterTool params) { final String bucket = params.getRequired("bucket"); final String s3file = params.getRequired("s3file"); final String localFile = params.getRequired("localFile"); TransferManager tx = TransferManagerBuilder.defaultTransferManager(); try { tx.download(bucket, s3file, new File(localFile)).waitForCompletion(); } catch (InterruptedException e) { System.out.println("Transfer interrupted"); } finally { tx.shutdownNow(); } }
public static void downloadFile(String bucket_name, String key_name, String file_path, boolean pause) { System.out.println("Downloading to file: " + file_path + (pause ? " (pause)" : "")); File f = new File(file_path); TransferManager xfer_mgr = TransferManagerBuilder.standard().build(); try { Download xfer = xfer_mgr.download(bucket_name, key_name, f); // loop with Transfer.isDone() XferMgrProgress.showTransferProgress(xfer); // or block with Transfer.waitForCompletion() XferMgrProgress.waitForCompletion(xfer); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } xfer_mgr.shutdownNow(); }
public static Download getFile(final ClientOptions clientOptions, final String bucketName, final String key, final File file) { LOGGER.debug(format("Receiving object %1$s as file %2$s from bucket %3$s", key, file.getAbsolutePath(), bucketName)); return getTransferManager(clientOptions).download(bucketName, key, file); }
public static Download getFile(final ClientOptions clientOptions, final GetObjectRequest getObjectRequest, final File file) { LOGGER.debug(format("Receiving object %1$s as file %2$s from bucket %3$s using GetObjectRequest", getObjectRequest.getKey(), file.getAbsolutePath(), getObjectRequest.getBucketName())); return getTransferManager(clientOptions).download(getObjectRequest, file); }
@Override public Download download(String s3BucketName, String s3Key, File file, TransferManager transferManager) { return transferManager.download(s3BucketName, s3Key, file); }
@Override public Download download(String s3BucketName, String s3Key, File file, TransferManager transferManager) { return transferManager.download(s3BucketName, s3Key, file); }
return download(getObjectRequest, file, 0);
return download(bucket, key, file, 0);
private void multiPartDownload(String keyName, File f) throws AmazonServiceException, AmazonClientException, InterruptedException { try { Download myDownload = tx.download(this.name, keyName, f); myDownload.waitForCompletion(); } finally { } }
private void downloadFile(TransferManager tx, String bucketName, String sourcePrefixKey, String destinationFile) throws Exception{ try { final File snapshotFile = new File(destinationFile); // Only create parent directory once, if it doesn't exist. final File parentDir = new File(snapshotFile.getParent()); if (!parentDir.isDirectory()) { final boolean parentDirCreated = parentDir.mkdirs(); if (!parentDirCreated) { LOGGER.error( "Error creating parent directory for file: {}. Skipping to next", destinationFile); return; } } snapshotFile.createNewFile(); final Download download = tx.download(bucketName, sourcePrefixKey, snapshotFile); download.waitForCompletion(); } catch (Exception e) { LOGGER.error("Error downloading the file {} : {}", destinationFile, e); throw new Exception(e); } }
return download(new GetObjectRequest(bucket, key), file, timeoutMillis);
Download download = tm.download(bucket, prefix, configFile); try { download.waitForCompletion();
downloads.put(file, tx.download(bucket, summary.getKey(), file)); downloadCount++; metrics.s3FilesDownloaded.mark(1);
TransferManager tx = new TransferManager( credentialProviderChain.getCredentials()); Download appDownload = tx.download(bucketName, key, file); try { LOGGER.info("Transfer: " + appDownload.getDescription());