2

Is there a script somewhere that will allow me to upload files to an archive.org project? I'd like to be able to simply run a script on a folder and have it upload and then spit out a list of URLs, for free, permanent, file hosting.

1 Answer 1

3

Actually, I should have spent about 30 more seconds on Google ...

http://www.archive.org/help/abouts3.txt says I can use the s3cmd tool: sudo apt-get install s3cmd And then edit the configuration file, so ~/.s3cfg looks like:

[default]
host_base = s3.us.archive.org
host_bucket = %(bucket)s.s3.us.archive.org
access_key = key
secret_key = key
use_https = False
verbosity = WARNING

Then use the following script to upload everything to archive.org:

#!/bin/sh
BASE_URL=http://archive.org/details/
BASE_HEADER=something-$(date -u +%s) #something that should be unique
echo Converts to PDF and uploads the contents of a directory given as the command-line argument.
echo Now converting PDF to JPG
for file in `ls $1/*.pdf`
do
   convert $file `echo $file | sed 's/\.pdf$/\.jpg/'`
done
echo Listing JPGs: #make sure the conversion worked
ls $1/*.jpg
echo Making the bucket...
s3cmd mb s3://$BASE_HEADER
echo Sleeping...#sometimes it takes a moment to be processed on their end
sleep 20
echo Uploading files...
for file in `ls $1`
do
        s3cmd put $1/$file s3://$BASE_HEADER/$file
done
echo $BASE_URL$BASE_HEADER

It's run like upload.sh ~/stuff/

1
  • (The converting to JPG was for the specific project I'm working on.)
    – AVB
    Mar 31, 2011 at 2:19

Not the answer you're looking for? Browse other questions tagged .