@Grab(group='org.apache.jackrabbit', module='jackrabbit-jcr2dav', version='2.2.9') import org.apache.commons.httpclient.auth.* import org.apache.commons.httpclient.* import org.apache.commons.httpclient.methods.* import org.apache.jackrabbit.webdav.* // WebDAV URL baseUrl = "http://localhost:8080/repository/default" path = "/" + java.net.URLEncoder.encode("テスト", "UTF-8") url = baseUrl + path println url try { client = new HttpClient() client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials('username', 'password')) method = new GetMethod(url + "/SF.JPG") client.executeMethod(method) new FileOutputStream("SF.JPG").withStream { it.write(method.getResponseBodyAsStream().getBytes()) } println(method.getStatusCode() + ":" + method.getStatusText()) } catch(HttpException ex){ println ex }
動作環境
groovy 1.8.2, JDK6 Update27, Jackrabbit 2.2.9
0 件のコメント:
コメントを投稿