使用MuleSoft CMIS连接器从Alfresco下载文件

编程入门 行业动态 更新时间:2024-10-19 14:34:45
本文介绍了使用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下载文件

本文发布于:2023-11-28 10:02:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641951.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接器   文件   MuleSoft   CMIS   Alfresco

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!