- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个java Cucumber Maven项目。现在我想在测试脚本执行完成后将所有报告推送到保管箱中。
我的主要目标是将报告文件夹推送到 Dropbox 上。
我正在使用以下 Maven 依赖项:
<dependency>
<groupId>com.dropbox.core</groupId>
<artifactId>dropbox-core-sdk</artifactId>
<version>1.7.2</version>
</dependency>
我知道这是旧的依赖项,但 Dropbox 提供的代码仅受此库支持。更高版本显示错误或已弃用的方法。
来源:
https://www.dropbox.com/developers-v1/core/start/java
我使用的代码如下:
public class DropBoxUpload {
public static void main(String[] args) throws IOException, DbxException {
// Get your app key and secret from the Dropbox developers website.
final String APP_KEY = "MyAppKey";
final String APP_SECRET = "MyAppSecretKey";
DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET);
DbxRequestConfig config = new DbxRequestConfig("JavaTutorial/1.0",
Locale.getDefault().toString());
DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(config, appInfo);
// Have the user sign in and authorize your app.
String authorizeUrl = webAuth.start();
System.out.println("1. Go to: " + authorizeUrl);
System.out.println("2. Click \"Allow\" (you might have to log in first)");
System.out.println("3. Copy the authorization code.");
String code = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();
// This will fail if the user enters an invalid authorization code.
DbxAuthFinish authFinish = webAuth.finish(code);
String accessToken = authFinish.accessToken;
DbxClient client = new DbxClient(config, accessToken);
System.out.println("Linked account: " + client.getAccountInfo().displayName);
File inputFile = new File("working-draft.txt");
FileInputStream inputStream = new FileInputStream(inputFile);
try {
DbxEntry.File uploadedFile = client.uploadFile("/magnum-opus.txt",
DbxWriteMode.add(), inputFile.length(), inputStream);
System.out.println("Uploaded: " + uploadedFile.toString());
} finally {
inputStream.close();
}
DbxEntry.WithChildren listing = client.getMetadataWithChildren("D:\\MavenJenkinsCI\\target\\cucumber-html-reports");
System.out.println("Files in the root path:");
for (DbxEntry child : listing.children) {
System.out.println(" " + child.name + ": " + child.toString());
}
FileOutputStream outputStream = new FileOutputStream("magnum-opus.txt");
try {
DbxEntry.File downloadedFile = client.getFile("/magnum-opus.txt", null,
outputStream);
System.out.println("Metadata: " + downloadedFile.toString());
} finally {
outputStream.close();
}
}
问题是当我运行这段代码时。它停留在下面一行:
String code = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();
知道为什么吗?
环境
如果您有任何解决方法,请分享。
这真的很有帮助。
最佳答案
Greg 提供了正确的依赖项和示例,引导我按要求完成任务。
新版本:
https://github.com/dropbox/dropbox-sdk-java
这里有一个上传示例:
我还在下面添加了一篇文章,它在集成过程中对我有帮助:
关于java - 如何使用java上传dropbox中的多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47096630/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!