On OpenCms 8 I had to adapt slightly to the new api, here the full code to download a file by CmsUUID:<br><br>if (CmsUUID.isValidUUID(request.getParameter("id"))) {<br> CmsUUID uuid = new CmsUUID(request.getParameter("id"));<br>
<br> CmsObject cmso = OpenCms.initCmsObject("Guest");<br> cmso.loginUser("user", "pass");<br><br> CmsResource res = cmso.readResource(uuid);<br> CmsFile file = cmso.readFile(res);<br>
<br> response.setHeader("Content-Disposition", "attachment; filename=\""+res.getName()+"\"");<br> response.setContentType("application/octet-stream");<br> response.setContentLength(file.getLength());<br>
OutputStream o = response.getOutputStream();<br> o.write(file.getContents());<br> o.flush();<br> o.close();<br>}<br><br><br><div class="gmail_quote">On 22 December 2008 13:37, Yves Glodt <span dir="ltr"><<a href="mailto:yg@mind.lu">yg@mind.lu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Florian,<br>
<br>
thank you very much, everything works now, access by uuid, and output of the<br>
file as well! I owe you a beer.<br>
<br>
Best regards,<br>
<span class="HOEnZb"><font color="#888888">Yves<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Monday 22 December <a href="tel:2008" value="+3522008">2008</a>, Florian Gutmann wrote:<br>
> Hi,<br>
><br>
> i think you have to use:<br>
> CmsFile file = CmsFile.upgrade(res, cmso);<br>
><br>
> instead of:<br>
> CmsFile file = new CmsFile(res);<br>
><br>
> If you want to read files by UUID from VFS you should be sure to use the<br>
> correct id.<br>
> There are two types of id's: the structureId and the resourceId.<br>
> cmsObject.readResource needs the strucutureId and not the resource id!<br>
> If you look at those id's they are nearly identically so you can oversee<br>
> that difference easyly.<br>
><br>
> Greetings,<br>
><br>
> Florian<br></div></div></blockquote></div><br>