- Cloudrail 教程
- Cloudrail - 首页
- Cloudrail - 概览
- Cloudrail - Android
- Cloudrail - Java
- Cloudrail - Node.js
- Cloudrail - IOS
- Cloudrail - 社交登录
- Cloudrail - 设置
- Cloudrail - 编码
- Cloudrail 有用资源
- Cloudrail - 快速指南
- Cloudrail - 有用资源
- Cloudrail - 讨论
Cloudrail - Java
本部分介绍如何使用 CloudRail 的 Java SDK。
设置
最简单的安装方法是通过 Maven。只需在 pom.xml 文件中添加以下内容 −
<dependencies> <dependency> <groupId>com.cloudrail</groupId> <artifactId>cloudrail-si-java</artifactId> <version>2.8.0</version> </dependency> </dependencies>
用法
以下示例演示了如何创建一个新文件夹,并将本地计算机上的文件上传到任何云存储提供商上新创建的文件夹。
java 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() { @Override public 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();
广告