Created
February 4, 2012 12:49
-
-
Save zaneli/1737650 to your computer and use it in GitHub Desktop.
「Dropbox Java API で過去リビジョンのファイルを取得」ブログ用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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