cancel
Showing results for 
Search instead for 
Did you mean: 

How to send webscript response as file (file download box)

g_rathod
Star Contributor
Star Contributor
Hi,

In alfresco 4 share enterprise, When I perform advance search, I place one more button called "Export Search", when search result gives me nodes (searched results).
e.g. Let say I got 5 results. Following are the steps I performed.
1) Get 5 nodeRefs from client side search.js
2) Calling repo side webscript from the same search.js (custom repo side webscript)
3) My repo side webscript will process those nodes and write data to one file (export as csv)
4) Now question is what output should I give in desc/or response file so, it will directly ask user to save/open that csv file ????


Let me know if anybody resolved same kind of thing.
15 REPLIES 15

power
Champ in-the-making
Champ in-the-making
Hi Ghanshyam,

I have similar kind of issue, did you resolved that?
I am storing file in tomcat/temp  but  streamContent would not expose file to share side as download prompt.

alfsender
Champ in-the-making
Champ in-the-making
Hi All,

were you able to resolve this, coz i am doing the same thing to export file from Share. I tried with declarative webscript and Content Stream but i am not getting content pop-up to save/save-as file.

please provide your inputs, that will be really help full.

Thanks.

grg021
Champ in-the-making
Champ in-the-making
hi, we're trying to the same as well. Has anyone got this down yet? we're using alfresco share 4.0.e.

Cheers.

mgupta
Champ in-the-making
Champ in-the-making
Hello,
Can you tell me how did you put a button to export advanced search results on the results screen

aleksczajka
Champ in-the-making
Champ in-the-making

aleksczajka
Champ in-the-making
Champ in-the-making
in case anyone still needs a response to this, here's how i did it…. all you need is a name.get.js and name.get.desc.xml and place them into your webScripts directory in Alfresco Share

name.get.desc.xml

three things to pay attention to: 1. "kind" attribute on the <webscript> tag, 2. empty "default" attribute on the <format> tag, 3. "required" content for the <transaction> tag


<webscript kind="org.alfresco.repository.content.stream">
<shortname>return file</shortname>
<description>return a file</description>
<url>/name/return/{name}url>
<format default="">extension</format>
<authentication>guest</authentication>
<transaction>required</transaction>
</webscript>


name.get.js

I search for my file first by name, but, you can search on other things as well, tags, internal columns, categories, text, etc. Just take a look into luceneSearch


// perform search
var nodes = search.luceneSearch("@cm\\:name:\""+url.extension+".xml\"");

//stream the first document
model.contentNode = nodes[0];


and that's it