homepage Welcome to WebmasterWorld Guest from 54.204.141.129
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

    
creating dummy files with exact sizes
httpwebwitch




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

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?

 

httpwebwitch




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

it took a while, but I made some using Notepad... precise to the byte

pinterface




msg:4061187
 5:02 am on Jan 15, 2010 (gmt 0)

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! :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved