Quint Stoffers
Quint Stoffers

Reputation: 800

PROPFIND Box.com and WebDav (JackRabbit)

In an attempt to bypass Box file/folder IDs and supporting a number of other services as well I decided to implement with WebDAV since I'm somewhat familiar with it on my linux box. I chose a library based on JackRabbit modified to work on Android which seemed to suit my needs. However, it wasn't long until I ran into a problem.

When attempting to list Box's root entries, multiStatus.getResponses() returns an empty array. When accessing another webdav server I get the responses as expected. Both servers return status code 207, as expected.

My code is below, any thoughts?

EDIT: I can move a file, though listing a directory's entries won't work :/

            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);
            }

Upvotes: 0

Views: 1141

Answers (1)

Peter
Peter

Reputation: 2599

While Box has some support for WebDAV, we only officially support it for iOS at the moment. Our testing has shown that our implementation of DAV works pretty well with the Windows native DAV client, as well as the Panic-Transmit Mac-specific client. Though the interactions there are not completely perfect.

Box WebDAV does not work well with the native osX (Mac) webDAV client. Expect huge delays as it looks like that client tries to load the whole tree before it displays anything.

Linux users may be able to tell you here on StackTrace which of the various OS webDAV clients/libs they've tried and which ones have worked better than others.

We do have plans to turn the crank and 10x improve our webDAV support sometime later this year, but we do not have a specific date, and just the nature of webDAV clients is such that even when we fix many of the issues with it, some client experiences on webDAV may still suck. For that reason we may only officially endorse a couple webDAV clients/libs per platform.

Hope that helps.

Upvotes: 1

Related Questions