上传至互联网档案馆 (archive.org) 的脚本

上传至互联网档案馆 (archive.org) 的脚本

是否有某个脚本允许我将文件上传到 archive.org 项目?我希望能够简单地在文件夹上运行脚本并将其上传,然后输出 URL 列表,以进行免费、永久的文件托管。

答案1

实际上,我应该在 Google 上多花 30 秒……

http://www.archive.org/help/abouts3.txt说我可以使用 s3cmd 工具: sudo apt-get install s3cmd 然后编辑配置文件,如下~/.s3cfg所示:

[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

然后使用以下脚本将所有内容上传到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

它的运行方式如下upload.sh ~/stuff/

相关内容