Search in sources :

Example 1 with DropboxException

use of com.dropbox.client2.exception.DropboxException in project skype-bot by toomasr.

the class DropboxDirPluginFileRepository method downloadPluginFiles.

private void downloadPluginFiles() throws DropboxException, IOException {
    String rootPath = "/" + Configuration.getProperty("dropbox.plugin.dir");
    Entry metadata = api.metadata(rootPath, 0, null, true, false, null);
    log.info("Got a response from dropbox, list has {} entries", metadata.contents.size());
    for (Entry entry : metadata.contents) {
        if (!entry.fileName().endsWith(".jar")) {
            continue;
        }
        String filepath = rootPath + "/" + entry.fileName();
        log.info("Downloading file {} from dropbox", filepath);
        DropboxInputStream fileStream = api.getFileStream(filepath, null);
        FileUtils.copyInputStreamToFile(fileStream, new File(dir, entry.fileName()));
    }
}
Also used : Entry(com.dropbox.client2.DropboxAPI.Entry) DropboxInputStream(com.dropbox.client2.DropboxAPI.DropboxInputStream) File(java.io.File)

Aggregations

DropboxInputStream (com.dropbox.client2.DropboxAPI.DropboxInputStream)1 Entry (com.dropbox.client2.DropboxAPI.Entry)1 File (java.io.File)1