Skip to content

Commit 6d81ce3

Browse files
BRIAN HOLYFIELDBRIAN HOLYFIELD
authored andcommitted
Add download example to Sample App
Add download example to Sample App
1 parent d05494f commit 6d81ce3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

SampleApplication/src/SendSafelyRefApp.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class SendSafelyRefApp {
1414

15-
public static void main(String[] args) throws SendFailedException, IOException, InvalidCredentialsException, CreatePackageFailedException, LimitExceededException, FinalizePackageFailedException, UploadFileException, ApproverRequiredException, RecipientFailedException
15+
public static void main(String[] args) throws SendFailedException, IOException, InvalidCredentialsException, CreatePackageFailedException, LimitExceededException, FinalizePackageFailedException, UploadFileException, ApproverRequiredException, RecipientFailedException, PackageInformationFailedException, DownloadFileException, PasswordRequiredException
1616
{
1717
/*
1818
* This example will read in the following command line arguments:
@@ -70,9 +70,16 @@ public static void main(String[] args) throws SendFailedException, IOException,
7070
// Package is finished, call the finalize method to make the package available for pickup and print the URL for access.
7171
PackageURL packageLink = sendSafely.finalizePackage(packageId, pkgInfo.getKeyCode());
7272
System.out.println("Success: " + packageLink.getSecureLink());
73-
73+
74+
// Now download the file and save a copy
75+
System.out.println("Downloading the file");
76+
Package pkgToDownload = sendSafely.getPackageInformationFromLink(packageLink.getSecureLink());
77+
for(File file : pkgToDownload.getFiles())
78+
{
79+
java.io.File downloadedFile = sendSafely.downloadFile(pkgToDownload.getPackageId(), file.getFileId(), pkgToDownload.getKeyCode(), new ProgressCallback());
80+
System.out.println("Downloaded File to path: " + downloadedFile.getAbsolutePath());
81+
}
7482
}
75-
7683
}
7784

7885
}

0 commit comments

Comments
 (0)