[opencms-dev] How to get the file size from items of cms:contentloop?

Mario Jäger m.jaeger at alkacon.com
Fri Jul 16 10:01:36 CEST 2010


Hi Daniel,

With this expression you can read the length of a resource in bytes:

${content.vfs.readResource['/index.html'].length}


Try it with that format in your jsp, please:

<cms:contentload ...>
  <cms:contentaccess var="content" />

  ...

    <cms:contentloop element="Attaches"> 

                <c:set var="file"><cms:contentshow element="${content.value['Attaches/File']}" /></c:set>
		<a href="${file}">${file}</a>
		${content.vfs.readResource[file].length}

    </cms:contentloop>

    ...

</cms:contentload>

-- 
Kind Regards,
Mario.
 
-------------------
Mario Jäger
 
Alkacon Software GmbH  - The OpenCms Experts                    
http://www.alkacon.com - http://www.opencms.org


Daniel Cassiani Rezende schrieb:
> Hi, folks,
>
>
> I have some Structured Content pages with a list of OpenCmsVfsFile (as declared in the XSD), and I need to show the name, link and file size of each item, but I have no idea of how.
>
> I need something like this:
>
> <ul>
> <cms:contentloop element="Attaches">
> 	<li>
> 		<a href="<cms:contentshow element=" Attaches/File" />">
> 		<cms:contentshow element=" Attaches/File" /></a>
> 		(<cms:contentshow element=" Attaches/File/fileSize" />)
> 	</li>
> </cms:contentloop>
> </ul>
>
> Obviously, <cms:contentshow element=" Attaches/File/fileSize" /> doesn't work.
>
> Any ideas???
>
>
>
> Thanks,
>
> - Daniel
>   
> ------------------------------------------------------------------------
>
> Esta mensagem e seus anexos podem conter informações confidenciais ou privilegiadas. Se você não é o destinatário dos mesmos você não está autorizado a utilizar o material para qualquer fim. Solicitamos que você apague a mensagem e avise imediatamente ao remetente. O conteúdo desta mensagem e seus anexos não representam necessariamente a opinião e a intenção da empresa, não implicando em qualquer obrigaçâo ou responsabilidade da parte da mesma. 
> This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. The contents of this message and its attachments do not necessarily express the opinion or the intention of the company, and do not implies any legal obligation or responsibilities from this company.   
>   
> ------------------------------------------------------------------------
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev



More information about the opencms-dev mailing list