Я пытаюсь реализовать клиент WebDav на Android. Для этого я использую версию JackRabbit, модифицированную для Android, которую я получил здесь (версия 2.2.6).
Я хочу подключиться к своей учетной записи на box.com и загрузить файл. С уважением, я не возражаю против коробки или любого другого, я просто случайно воспользовался этим.
Что ж, продолжая box.com, согласно (эта ссылка) [https://support.box.com/hc/en-us/articles/200519748-Does-Box-support-WebDAV-] Я должен использовать "https://dav.box.com/dav" в качестве сервера.
Я перешел по этим ссылкам, чтобы создать свой код:
- http://jackrabbit.apache.org/api/2.1/org/apache/jackrabbit/webdav/client/methods/package-summary.html.
- http://wiki.apache.org/jackrabbit/WebDAV
Я получаю исключение UnknownHostException с указанием URL-адреса, который я использую для сервера ("https://dav.box.com/dav ") не удалось найти.
Есть идеи, почему это не работает? В противном случае, пробовали ли вы с другим сервером и преуспели?
Мой код здесь:
Thread t = new Thread() {
public void run(){
try {
String uri = "https://app.box.com/files";
HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setHost(uri);
HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
int maxHostConnections = 20;
params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
connectionManager.setParams(params);
HttpClient client = new HttpClient(connectionManager);
client.setHostConfiguration(hostConfig);
Credentials creds = new UsernamePasswordCredentials("USER", "PASSWORD");
client.getState().setCredentials(AuthScope.ANY, creds);
String baseUrl = "/";
File f = new File(Environment.getExternalStorageDirectory() + "/working-draft.txt");
PutMethod method = new PutMethod(baseUrl + "/" + f.getName());
RequestEntity requestEntity = new InputStreamRequestEntity(
new FileInputStream(f));
method.setRequestEntity(requestEntity);
client.executeMethod(method);
}
catch (FileNotFoundException fnfe){
Log.i("SERVICE", "FileNotFoundException");
}
catch (HttpException he){
Log.i("SERVICE", "HttpException");
}
catch (IOException ioe){
Log.i("SERVICE", "IOException");
}
catch (Exception e){
Log.i("SERVICE", "Other Exception");
}
}
};
t.start();