How to get the size of a remote file?

Author Message

Marco Zinn

Friday 10 December 2010 10:51:55 am

Hi there,

I'm looking for a way (template operator) to retrieve the size of a remote file. I have the full URL of the file in a text line attribute and I want to create a link in the template to the file. Works nice. Now, i want to display the (remote) file size next to the link.

How can this be done? I did not find a template operator for this yet. Although, there does not seem to exist a PHP function for this. I thought, i could use "filesize" for this (http://php.net/manual/de/function.filesize.php ) and use it throught PHPOperatorList , but this is only intended for local files.

Any idea?

Marco
http://www.hyperroad-design.com

Carlos Revillo

Friday 10 December 2010 11:24:52 am

Maybe you can have a look at some of the comments to filesize function and do a function working like that.

have a look at

http://www.php.net/manual/en/function.filesize.php#92462

Ivo Lukac

Monday 13 December 2010 12:56:11 am

"

Hi there,

I'm looking for a way (template operator) to retrieve the size of a remote file. I have the full URL of the file in a text line attribute and I want to create a link in the template to the file. Works nice. Now, i want to display the (remote) file size next to the link.

How can this be done? I did not find a template operator for this yet. Although, there does not seem to exist a PHP function for this. I thought, i could use "filesize" for this (http://php.net/manual/de/function.filesize.php ) and use it throught PHPOperatorList , but this is only intended for local files.

Any idea?

"

Try it with curl. E.g.. http://snipplr.com/view/29/get-remote-filesize/

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Marco Zinn

Tuesday 14 December 2010 1:47:55 pm

Thanks for your replies.

So, i read, that currently, there is no built-in or otherwise "easy-to-get" option for this. One would need to write a (simple) template operator for it, right?

Marco
http://www.hyperroad-design.com

Ivo Lukac

Wednesday 15 December 2010 12:31:33 am

"

Thanks for your replies.

So, i read, that currently, there is no built-in or otherwise "easy-to-get" option for this. One would need to write a (simple) template operator for it, right?

"

In short, yes :)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:16:31
Script start
Timing: Jan 18 2025 02:16:31
Module start 'layout'
Timing: Jan 18 2025 02:16:31
Module start 'content'
Timing: Jan 18 2025 02:16:33
Module end 'content'
Timing: Jan 18 2025 02:16:33
Script end

Main resources:

Total runtime1.7775 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.0313152.6406
Module start 'layout' 0.00640.0041 740.671939.4844
Module start 'content' 0.01041.7654 780.1563608.9375
Module end 'content' 1.77580.0017 1,389.093816.1406
Script end 1.7775  1,405.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.2163160.0002
Check MTime0.00150.0850160.0001
Mysql Total
Database connection0.00090.049710.0009
Mysqli_queries1.695995.4099680.0249
Looping result0.00090.0528660.0000
Template Total1.736897.720.8684
Template load0.00230.128720.0011
Template processing1.734597.580020.8672
Template load and register function0.00010.006910.0001
states
state_id_array0.00170.095110.0017
state_identifier_array0.00230.131620.0012
Override
Cache load0.00200.1116340.0001
Sytem overhead
Fetch class attribute can translate value0.00090.048630.0003
Fetch class attribute name0.00140.078470.0002
XML
Image XML parsing0.00130.074630.0004
class_abstraction
Instantiating content class attribute0.00000.001090.0000
General
dbfile0.00130.0740230.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs