filesize

Prevent loading from remote source if file is larger than a given size

孤街浪徒 提交于 2019-12-04 16:51:20
Let's say I want XML Files only with upto 10MB to be loaded from a remote server. Something like $xml_file = "http://example.com/largeXML.xml";// size= 500MB //PRACTICAL EXAMPLE: $xml_file = "http://www.cs.washington.edu/research/xmldatasets/data/pir/psd7003.xml";// size= 683MB /*GOAL: Do anything that can be done to hinder this large file from being loaded by the DOMDocument without having to load the File n check*/ $dom = new DOMDocument(); $dom->load($xml_file /*LOAD only IF the file_size is <= 10MB....else...echo 'File is too large'*/); How can this possibly be achieved?.... Any idea or

Any way to analyze the size of a SWF built in Flex?

 ̄綄美尐妖づ 提交于 2019-12-04 13:42:12
问题 I have a Flex application that seems larger than it should be. There is a lot of code in it, but not a lot of assets and it just seems large, but I'm not sure how to go about figuring out where the space is going. I know about the –link-report option, but it only gives the sizes of externally linked library classes. I'm very interested in seeing a report of the sizes of all the classes and resources in my application and it would be a huge bonus if I could also view their dependencies. Not

How to retrieve the size of a file before uploading it?

十年热恋 提交于 2019-12-04 07:39:56
I have an file input tag in my web app. I'd like to check that the file isn't too big before sending it to the server. Of course, I still have validation server side. Is there any way to do this with JavaScript? It must work in IE7+ and FF3+. Thank you. EDIT: somefileinputobject.files[0].filesize works in FF, but not IE. It's a hard problem. You have to do it with AJAX, and use the filesize headers sent by the browser to the server on the POST request. Yahoo's UI Library has a tool to help with this. YUI Uploader Javascript cannot do this. It would have serious security issues. Perhaps flash

Why does chown increase size of docker image?

时光毁灭记忆、已成空白 提交于 2019-12-04 05:05:31
I can't understand why the 'chown' command should increase the size of my docker image? The following Dockerfile creates an image of size 5.3MB: FROM alpine:edge RUN adduser example -D -h /example -s /bin/sh This example however creates an image of size 8.7MB: FROM alpine:edge RUN adduser example -D -h /example -s /bin/sh && \ chown -R example.example /lib Why? Note: My actual dockerfile is of course much longer than this example and therefore the increase in image size is also quite larger. That's why I even care.. Every step in a Dockerfile generates a new intermediate image, or "layer",

PHP: get remote file size with strlen? (html)

自古美人都是妖i 提交于 2019-12-04 01:58:13
问题 I was looking at PHP docs for fsockopen and whatnot and they say you can't use filesize() on a remote file without doing some crazy things with ftell or something (not sure what they said exactly), but I had a good thought about how to do it: $file = file_get_contents("http://www.google.com"); $filesize = mb_strlen($file) / 1000; //KBs, mb_* in case file contains unicode Would this be a good method? It seemed so simple and good to use at the time, just want to get any thoughts if this could

perl file size calculation not working

六眼飞鱼酱① 提交于 2019-12-03 22:23:22
问题 I am trying to write a simple perl script that will iterate through the regular files in a directory and calculate the total size of all the files put together. However, I am not able to get the actual size of the file, and I can't figure out why. Here is the relevant portion of the code. I put in print statements for debugging: $totalsize = 0; while ($_ = readdir (DH)) { print "current file is: $_\t"; $cursize = -s $_; print "size is: $cursize\n"; $totalsize += $cursize; } This is the output

Is there a way to get the size of a file in .NET using a static method?

时光毁灭记忆、已成空白 提交于 2019-12-03 22:03:36
I know the normal way of getting the size of a file would be to use a FileInfo instance: using System.IO; class SizeGetter { public static long GetFileSize(string filename) { FileInfo fi = new FileInfo(filename); return fi.Length; } } Is there a way to do the same thing without having to create an instance of FileInfo, using a static method? Maybe I'm trying to be overly stingy with creating a new instance every time I want a file size, but take for example trying to calculate the total size of a directory containing 5000+ files. As optimized as the GC may be, shouldn't there be a way to do

How to reduce the size of merged PDF/A-1b files with pdfbox or other java library

倖福魔咒の 提交于 2019-12-03 20:29:57
问题 Input : A list of (e.g. 14) PDF/A-1b files with embedded fonts. Processing : Doing a simple merge with Apache PDFBOX. Result : 1 PDF/A-1b file with large (too large) file size. (It is almost the sum of the size of all the source files). Question : Is there a way to reduce the file size of the resulting PDF? Idea : Remove redundant embedded fonts. But how to? And is it the right way to do? Unfortunately the following code is not doing the job, but is highlighting the obvious problem. try

human readable file size

寵の児 提交于 2019-12-03 18:50:40
问题 function humanFileSize($size) { if ($size >= 1073741824) { $fileSize = round($size / 1024 / 1024 / 1024,1) . 'GB'; } elseif ($size >= 1048576) { $fileSize = round($size / 1024 / 1024,1) . 'MB'; } elseif($size >= 1024) { $fileSize = round($size / 1024,1) . 'KB'; } else { $fileSize = $size . ' bytes'; } return $fileSize; } ... works great except: I can't manually choose in what format I need to display, say i want to show in MB only whatever the file size is. Currently if its in the GB range,

Finding file size and last modified of SFTP oldest file using Java

笑着哭i 提交于 2019-12-03 18:14:09
问题 I'm using JSch to get files from an SFTP server, but I'm trying to figure out a way to only get the oldest file, and to make sure that it is not currently being written to. The way I imagine myself doing this is first finding which file in the specified remote folder is oldest. I would then check the file size, wait x seconds (probably about 10, just to be safe) and then check it again. If the file size has not changed, I download the file and process it. However, I have no idea how to do