Welcome to WebmasterWorld Guest from 54.145.209.34

Forum Moderators: phranque

creating dummy files with exact sizes

   
3:49 am on Jan 15, 2010 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I'm testing an uploader.

The max size is 60MB - that's set by someone else due to platform limitations... I'm just making the UI

anyhow, to test it I need some files that are exactly at, less than, and slightly greater than the max size.

Their definition of Megabyte is 1024^2 bytes
so the max is actually 60 * 1024 * 1024 = 62,914,560 bytes

So - I need at least three files, with exact sizes of
62914559
62914560
62914561

Is there a simple way to generate files like that? What software should I use?

4:13 am on Jan 15, 2010 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



it took a while, but I made some using Notepad... precise to the byte
5:02 am on Jan 15, 2010 (gmt 0)

5+ Year Member



If you happen to run into this problem in the future, and you have a *nix box handy, you can do:
head -c [i]desired-size-in-bytes[/i] /dev/random > [i]name-of-file[/i]

for a file of random bytes or
head -c [i]desired-size-in-bytes[/i] /dev/zero > [i]name-of-file[/i]

for a file of nul characters (all zeros).

for (1..byte-size) print 'a';
in your-favorite-language isn't too bad, either.

Notepad, on the other hand, is just plain silly! :)

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month