with your solution the filename is "undefinded". Is it possible to cast file to org.apache.cocoon.servlet.multipart.Part to access the filename attribute?
----- Ursprüngliche Mail ---- Von: Thomas Markus <[email protected]> An: [email protected] Gesendet: Dienstag, den 19. April 2011, 10:02:48 Uhr Betreff: Re: [C2.2] Original name of uploaded file in your flowscript do something like: /** @type org.apache.cocoon.servlet.multipart.Part */ var file = form.getChild("uploadFile").value; if (file!=null) { // no file upload var filename = file.filename; // check for single name and change extension } regards Thomas Am 19.04.2011 09:47, schrieb Matthias Müller: > I am using a fileupload widget and flowscript. > My flow function looks like that: > > function myTask() { > var form = new Form(cocoon.parameters["definitionURI"]); > form.showForm("myTask-form"); > var file = form.getChild("uploadFile"); > var viewData = { "filename" : file.getValue() + ".pdf" }; > > cocoon.sendPage("myTask.pdf", viewData); > } > > In the sitemap.xmap I do the fo transformation and renaming: > > <map:match pattern="myTask.pdf"> > <map:generate type="file" src="upload://uploadFile"/> > <map:transform type="xslt-saxon" src="stylesheets/toFO.xsl" /> > <map:act type="set-header"> > <map:parameter name="Content-Type" > value="application/x-download"/> > <map:parameter name="Content-Disposition" value="attachment ; > filename={flow-attribute:filename}"/> > </map:act> > <map:serialize type="fo2pdf"/> > </map:match> > > The only problem is that i receive the full path (value of the upload widget) > instead of the name of the uploaded file. > > How and where (flow script / sitemap) do i need to resolve the filename? The > getValue() method seems to only return the widgets value. Do I need to cast the > form.getChild("uploadFile") to org.apache.cocoon.servlet.multipart.Part >instead? > How can I achieve that? > > Thanks, Matthias > > > > > ----- Ursprüngliche Mail ---- > Von: Thomas Markus<[email protected]> > An: [email protected] > Gesendet: Dienstag, den 19. April 2011, 7:47:42 Uhr > Betreff: Re: [C2.2] Original name of uploaded file > > Hi, > > when using a fileupload widget your value is of type > org.apache.cocoon.servlet.multipart.Part > It contains upload filename and content > > regards > Thomas > > Am 18.04.2011 14:46, schrieb Matthias Müller: >> Hi there, >> >> in my cocoon app i have a simple transformation xml -> fo -> pdf. The >> resulting >> pdf needs to be named as the uploaded xml file + .pdf extension. >> How can I achieve that? Is there a way to access the data of the uploaded file >> in the sitemap.xmap / flow.js? >> >> Matthias >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
