Cloudrail - Java

This section gives an introduction on how to use CloudRail's Java SDK.


The easiest way to install is via Maven. It suffices to add the following to your pom.xml file −



The following example shows how to create a new folder and upload a file from the local machine to the newly created folder on any cloud storage provider.

CloudRail.setAppKey("[CloudRail License Key]");

// CloudStorage cs = new Box(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
// CloudStorage cs = new OneDrive(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
// CloudStorage cs = new GoogleDrive(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
CloudStorage cs = new Dropbox(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
new Thread() {
   public void run() {
      InputStream stream = null;
      try {
         stream = getClass().getResourceAsStream("Data.csv");
         long size = new File(getClass().getResource("Data.csv").toURI()).length();
         cs.upload("/TestFolder/Data.csv", stream, size, false);
      } catch (Exception e) {
         // TODO: handle error
      } finally {
         // TODO: close stream