爲了繞過Box文件/文件夾ID並支持許多其他服務,我決定使用WebDAV來實現,因爲我在我的Linux機器上有點熟悉它。我選擇了一個基於JackRabbit的庫進行了修改,以在Android上工作,這似乎滿足了我的需求。但是,直到我遇到問題時纔會這樣。PROPFIND Box.com和WebDav(JackRabbit)
當試圖列出Box的根條目時,multiStatus.getResponses()返回一個空數組。當訪問另一個webdav服務器時,我會按照預期收到響應。如預期的那樣,兩臺服務器都返回狀態碼207。
我的代碼如下,有什麼想法?
編輯:我可以移動文件,但列出一個目錄的條目將不起作用:/
String host = "https://www.box.com/dav/";
//String host = "http://demo.sabredav.org/";
hostConfig = new HostConfiguration();
hostConfig.setHost(host);
HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
int maxHostConnections = 20;
params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
connectionManager.setParams(params);
client = new HttpClient(connectionManager);
Credentials creds = new UsernamePasswordCredentials("BOXEMAILADDRESS", "MYBOXPASSWORD");
//Credentials creds = new UsernamePasswordCredentials("testuser", "test");
client.getState().setCredentials(AuthScope.ANY, creds);
client.setHostConfiguration(hostConfig);
try
{
String propfindUri = host;
DavMethod method = new PropFindMethod(propfindUri, DavConstants.PROPFIND_ALL_PROP, DavConstants.DEPTH_1);
client.executeMethod(method);
Log.i("Status: " + method.getStatusCode());
MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
Log.i("Length: " + responses.length);
for(MultiStatusResponse response : responses)
{
Log.i("File: " + response.getHref());
}
}
catch (Exception e)
{
Log.printStackTrace(e);
}
獲取HTTP跟蹤。 –
我也遇到了來自Box.com的WebDAV上市結果的問題。我在iOS上使用DAVKit,它可以很好地處理iDisk和其他服務,但是Box會返回一個空的PROPFIND,以及我試過的任何路徑和URL的組合。 – DaGaMs