Cloudrail Tutorial
Cloudrail Useful Resources
Selected Reading
- Cloudrail - Coding
- Cloudrail - Setup
- Cloudrail - Social Login
- Cloudrail - IOS
- Cloudrail - Node.js
- Cloudrail - Java
- Cloudrail - Android
- Cloudrail - Overview
- Cloudrail - Home
Cloudrail Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Cloudrail - Java
Cloudrail - Java
This section gives an introduction on how to use CloudRail s Java SDK.
Setup
The easiest way to install is via Maven. It suffices to add the following to your pom.xml file −
<dependencies> <dependency> <groupId>com.cloudrail</groupId> <artifactId>cloudrail-si-java</artifactId> <version>2.8.0</version> </dependency> </dependencies>
Usage
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.
java CloudRail.setAppKey("[CloudRail License Key]"); // CloudStorage cs = new Box(redirectReceiver, "[cpentIdentifier]", "[cpentSecret]", "[redirectUri]", "[state]"); // CloudStorage cs = new OneDrive(redirectReceiver, "[cpentIdentifier]", "[cpentSecret]", "[redirectUri]", "[state]"); // CloudStorage cs = new GoogleDrive(redirectReceiver, "[cpentIdentifier]", "[cpentSecret]", "[redirectUri]", "[state]"); CloudStorage cs = new Dropbox(redirectReceiver, "[cpentIdentifier]", "[cpentSecret]", "[redirectUri]", "[state]"); new Thread() { @Override pubpc void run() { cs.createFolder("/TestFolder"); 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 } } }.start();Advertisements