Skip to content

Instantly share code, notes, and snippets.

@zaneli
Created February 4, 2012 12:49
Show Gist options
  • Select an option

  • Save zaneli/1737650 to your computer and use it in GitHub Desktop.

Select an option

Save zaneli/1737650 to your computer and use it in GitHub Desktop.
「Dropbox Java API で過去リビジョンのファイルを取得」ブログ用
package com.zaneli.dropbox;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import com.dropbox.client2.DropboxAPI;
import com.dropbox.client2.RESTUtility;
import com.dropbox.client2.exception.DropboxException;
import com.dropbox.client2.session.AbstractSession;
public class RevParamEnableDropboxAPI<T extends AbstractSession> extends DropboxAPI<T> {
public RevParamEnableDropboxAPI(T session) {
super(session);
}
@Override
public DropboxInputStream getFileStream(
String path, String rev) throws DropboxException {
assertAuthenticated();
if (!path.startsWith("/")) {
path = "/" + path;
}
String url = "/files/" + session.getAccessType() + path;
String target = RESTUtility.buildURL(
session.getContentServer(),
VERSION,
url,
new String[] {
"locale", session.getLocale().toString(),
"rev", rev // この行を追加しただけ
});
HttpGet req = new HttpGet(target);
session.sign(req);
HttpResponse response = RESTUtility.execute(session, req);
return new DropboxInputStream(req, response);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment