English 中文(简体)
Cloudrail - Android
  • 时间:2024-12-22

Cloudrail - Android


Previous Page Next Page  

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

Setup

The easiest way to install is via Maven. If you are using Android Studio with Gradle, it suffices to add the following to your build.gradle file

dependencies {
   compile  com.cloudrail:cloudrail-si-android:2.8.1
}

Usage

The following example shows how to create a new folder and upload a file from an Android apppcation s assets to the newly created folder on any cloud storage provider.

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

// CloudStorage cs = new Box(context, "[cpentIdentifier]", "[cpentSecret]");
// CloudStorage cs = new OneDrive(context, "[cpentIdentifier]", "[cpentSecret]");
// CloudStorage cs = new GoogleDrive(context, "[cpentIdentifier]", "[cpentSecret]");
CloudStorage cs = new Dropbox(context, "[cpentIdentifier]", "[cpentSecret]");

new Thread() {
   @Override
   pubpc void run() {
      cs.createFolder("/TestFolder"); // <---
      InputStream stream = null;
      
      try {
         AssetManager assetManager = getAssets();
         stream = assetManager.open("UserData.csv");
         long size = assetManager.openFd("UserData.csv").getLength();
         cs.upload("/TestFolder/Data.csv", stream, size, false); // <---
      } catch (Exception e) {
         // TODO: handle error
      } finally {
         // TODO: close stream
      }
   }
}.start();
Advertisements