As promised, please find below a very rudimentary script written in Perl
which supports GET and PUT requests.
# PUT/GET support
# Written by Aprelium Technologies - 2005 - http://www.aprelium.com
# Released in the public domain
# This is the only constant that must be updated before using the script
$files_path = 'C:/Upload';
# ---
$file_full_path = "$files_path/$ENV{PATH_INFO}";
if ($ENV{'REQUEST_METHOD'} eq 'GET')
{
if (!(-e $file_full_path) || !open(FILE, $file_full_path))
{
print "Status: 404\n\nNot found";
exit(1);
}
print "Content-type: application/octet\n\n";
binmode FILE;
binmode STDOUT;
read(FILE, $in, -s $file_full_path);
print STDOUT $in || die "Writing Error";
close(FILE) || die "Closing Error";
}
elsif ($ENV{'REQUEST_METHOD'} eq 'PUT')
{
if (!open(FILE, "+>$file_full_path"))
{
print "Status: 403\n\nAccess is denied";
exit(1);
}
binmode FILE;
binmode STDIN;
read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
print FILE $in || die "Writing Error";
close(FILE) || die "Closing Error";
print "Status: 201\n\nUpload successful";
}
else
{
print "Status: 405\n\nUnsupported HTTP method!";
}
Add Perl support to the server as explained in
http://www.aprelium.com/abyssws/perl.html and copy the script for example in
htdocs/.
Create a directory where the uploads should be stored and update the
$files_path variable value in the script accordingly. Please note that in
Perl \ should be written as \\. You can also use / instead of \ in path
names.
To try the script, we have used the command line tool curl. Its Windows
version can be downloaded from
http://curl.haxx.se/download/curl-7.14.0-win32-ssl-sspi.zip .
To PUT a file on the server, use the following command line:
curl -T FILE_TO_UPLOAD http://YOUR_SITE/getput.pl/NEW_FILE_NAME
To see the file, browse: http://YOUR_SITE/getput.pl/NEW_FILE_NAME
The script is very rudimentary but it has all the basic building blocks of a
PUT/GET system.
For more ideas, we recommend having a look on the more complex script
http://okmij.org/ftp/Perl/MCHFS-server.pl-txt .