使用MuleSoft CMIS连接器从Alfresco下载文件 [英] Downloading files from Alfresco with MuleSoft CMIS connector

查看:56
本文介绍了使用MuleSoft CMIS连接器从Alfresco下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MuleSoft CMIS连接器有一点问题。我有一个可以从Alfresco上传和下载文件的应用程序。我通过AtomPub连接到Alfresco,并使用CMIS对Alfresco进行所有操作。

I have a little problem with the MuleSoft CMIS connector. I have an application that uploads and downloads files from Alfresco. I connect to Alfresco through AtomPub and use CMIS for all actions towards the Alfresco.

问题是这样的:
我曾经从存储库中获取对象,并且工作正常。在我的流程中,我添加了一个从流程中获取对象的组件,该组件的类型为 DocumentImpl ,获得 InputStream ,将其转换为对象并返回。浏览器开始下载文件,但不知道文件是什么,因为没有附加扩展名。

The problem is this: I used to get the object from the repository and it worked fine. In my flow I added one component that takes the object from the flow, which is of type DocumentImpl, get InputStream, cast it to an Object and return it. The browser starts the download of the file but it has no idea what the file is because it has no extension attached to it.

最后一个问题:如何将扩展名附加到正在下载的文件上?

And finally the question: How do I attach the extension to the file being downloaded?

编辑添加的一些代码

@Override
public Object onCall(MuleEventContext eventContext)引发异常{

@Override public Object onCall(MuleEventContext eventContext) throws Exception {

    MuleMessage mes = eventContext.getMessage();
    System.out.println("Message is :" +mes);

    DocumentImpl doc = mes.getPayload(DocumentImpl.class);

    HttpResponse res = new HttpResponse();
    InputStream a = doc.getContentStream().getStream();
    String m = doc.getContentStreamMimeType();
    String n = doc.getContentStreamFileName();

    res.setBody(mes);


    return a;
}


推荐答案

好,我解决了这个问题。基本上,执行此操作的最佳方法是将流程更改为以下内容:

Ok i solved the problem. Basically the best way to do this is to change the flow to this:

    <set-payload value ="#[payload.getContentStream()]" />

    <set-variable value="#[payload.getMimeType()]" variableName="mime" doc:name="Variable" />
    <set-variable value="#[payload.getFileName()]" variableName="name" doc:name="Variable" />

    <!-- Set Content-Type to stored mimetype -->        
    <set-property value="#[flowVars['mime']]" propertyName="Content-Type" />
    <set-property propertyName="File-Name" value="#[flowVars['name']]"/>
    <set-property value="attachment; filename=#[flowVars['name']]" propertyName="Content-Disposition" />

这应该在

这将从有效载荷中获取mime类型和文件名,然后将其返回!

This takes mime type and file name from the payload and returns it!

这篇关于使用MuleSoft CMIS连接器从Alfresco下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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