如何使用liferay jsonws或任何其他方式从外部应用程序从Liferay下载文档 [英] How to download documents from liferay from outside application ..using liferay jsonws or any other way

查看:184
本文介绍了如何使用liferay jsonws或任何其他方式从外部应用程序从Liferay下载文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用liferay/api/secure/jsonws服务从外部应用程序上载文档,获取文档,就像我也要下载文档一样,我检查了liferay jsonws,没有方法或我可以用来下载服务,或者我不知道该服务,请建议我一种使用jsonws或其他任何方式从外部应用程序下载文档的方法.

Hi i am using liferay/api/secure/jsonws services to upload documents, getting documents, from a outside application , in the same way i want to download the documents also, i checked my liferay jsonws , there is no method or service which i can use for download , or i don't know about it , please suggest me a way to download documents from outside application , by using jsonws or any other way is also fine.

在我知道如何下载文档后进行编辑.

Edit after i got to know how to download document.

我尝试使用getURl从外部应用程序下载liferay文档,但是每次获取所有文档时,我都会获得liferay登录页面内容

Hi I tried to download liferay document from outside application by using getURl, but every time for all document i am getting liferay login page content

我已经尝试过get-file-as-stream json-rpc调用,但这也给了我空响应

i have already tried get-file-as-stream json-rpc call but that also giving me null response

我使用的代码是:

 final HttpHost targetHost = new HttpHost(hostname.trim());
    System.out.println(targetHost.getHostName());
    UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);
    System.out.println(creds);
    final AuthScope authscope = new AuthScope(targetHost);
    httpclient.getCredentialsProvider().setCredentials(authscope, creds);

    final AuthCache authCache = new BasicAuthCache();
    final BasicScheme basicAuth = new BasicScheme();
    authCache.put(targetHost, basicAuth);

    final BasicHttpContext localContext = new BasicHttpContext();
    localContext.setAttribute(ClientContext.AUTH_CACHE, authCache);

    final HttpGet httpget = new HttpGet(hostname+"/documents/" + groupId + "/" + folderId + "/" + filename);


    final HttpResponse response = httpclient.execute( httpget, localContext);

    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
        final org.apache.http.HttpEntity entity = response.getEntity();

        if (entity != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            entity.writeTo(baos);
            return baos.toByteArray();
        }
    }
    return null;
} finally {
    httpclient.getConnectionManager().shutdown();
}

}

我正在添加基本身份验证标头,将纠正用户名和密码,不知道此登录页面将如何出现,是否需要更改任何权限或任何配置问题,请提供帮助.

i am adding basic auth header will correct username and password, don't know how this login page is coming, is there any permission which i need to change or any configurations issue, please help in this.

推荐答案

您可以使用Liferay WebDav服务从文档库下载文件.单击文件条目(WebDAV URL toogle链接)时,可以在控制面板内部检查下载路径.路径通常看起来像:/webdav/{site-name}/document_library/{folder-name}/{file-name} 否则,您可以模仿Liferay在documents-media portlet内部创建的请求URL,以下载文件条目. 但是,当访客看不到您的文件(和文件夹)时,应该注意身份验证.

You could use the Liferay WebDav Services to download files from your document-library. The paths to download can be inspected inside of the control-panel when clicking on a file entry (WebDAV URL toogle link). The paths usually look like: /webdav/{site-name}/document_library/{folder-name}/{file-name} Otherwise, you could mimic the request URLs Liferay creates inside the documents-media portlet to download the file entry. But you should take care about authentication, when your files (and folders) are not visible to guests.

这篇关于如何使用liferay jsonws或任何其他方式从外部应用程序从Liferay下载文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆