private boolean upload(AmazonS3 s3, File sourceFile) throws MojoExecutionException
{
TransferManager mgr = new TransferManager(s3);
Transfer transfer;
if (sourceFile.isFile()) {
transfer = mgr.upload(bucketName, destination, sourceFile);
} else if (sourceFile.isDirectory()) {
transfer = mgr.uploadDirectory(bucketName, destination, sourceFile, recursive);
} else {
throw new MojoExecutionException("File is neither a regular file nor a directory " + sourceFile);
}
try {
getLog().debug("Transferring " + transfer.getProgress().getTotalBytesToTransfer() + " bytes...");
transfer.waitForCompletion();
getLog().info("Transferred " + transfer.getProgress().getBytesTransfered() + " bytes.");
} catch (InterruptedException e) {
return false;
}
return true;