Forums / Setup & design / How to get the size of a remote file?

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

eZ debug

Timing: Feb 01 2025 07:49:26
Script start
Timing: Feb 01 2025 07:49:26
Module start 'content'
Timing: Feb 01 2025 07:49:26
Module end 'content'
Timing: Feb 01 2025 07:49:26
Script end

Main resources:

Total runtime0.0240 sec
Peak memory usage4,096.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0109 679.0469214.7969
Module start 'content' 0.01090.0035 893.8438189.5547
Module end 'content' 0.01440.0096 1,083.3984793.3281
Script end 0.0240  1,876.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.004016.6619120.0003
Check MTime0.00114.4418120.0001
Mysql Total
Database connection0.00114.690910.0011
Mysqli_queries0.007129.543840.0018
Looping result0.00000.174720.0000
Template Total0.009137.910.0091
Template load0.002510.455610.0025
Template processing0.006627.450910.0066
Override
Cache load0.00229.244910.0022
General
dbfile0.00031.3645100.0000
String conversion0.00000.038730.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs