
从命令行共享简单快速的文件。此代码包含服务器,其中包含创建自己实例所需的一切。
Transfer.sh当前支持S3(Amazon S3),GDRIVE(Google Drive),Storj(Storj)提供商和本地文件系统(本地)。
@stefanbenten恰好是该存储库的维护者,并且是在存储库中举办众所周知的公共安装的人。
无论如何,这两者都是无关的,并且回购并不是任何Pubblic安装的指导请求和问题的地方。
出于安全原因,在存储库本身中,不会在存储库中宣传或提及该软件的第三方公共安装。
我的官方位置,@aspacca作为仓库的维护者,是,如果您想使用软件,则应托管自己的安装。
$ curl -v --upload-file ./hello.txt https://transfer.sh/hello.txt$ gpg --armor --symmetric --output - /tmp/hello.txt | curl --upload-file - https://transfer.sh/test.txt$ curl https://transfer.sh/1lDau/test.txt | gpg --decrypt --output /tmp/hello.txt$ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal$ curl -X DELETE < X-Url-Delete Response Header URL > $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H " Max-Downloads: 1 " # Limit the number of downloads$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H " Max-Days: 1 " # Set the number of days before deletion$ curl --upload-file ./hello.txt https://your-transfersh-instance.tld/hello.txt -H " X-Encrypt-Password: test " # Encrypt the content sever side with AES265 using "test" as password$ curl https://your-transfersh-instance.tld/BAYh0/hello.txt -H " X-Decrypt-Password: test " # Decrypt the content sever side with AES265 using "test" as password URL用于要求删除文件并作为响应标头返回。
curl -sD - --upload-file ./hello.txt https://transfer.sh/hello.txt | grep -i -E ' transfer.sh|x-url-delete '
x-url-delete: https://transfer.sh/hello.txt/BAYh0/hello.txt/PDw0NHPcqU
https://transfer.sh/hello.txt/BAYh0/hello.txt在示例中查看良好的用法示例。
创建直接下载链接:
https://transfer.sh/1ldau/test.txt-> https://transfer.sh/get/1ldau/test.txt
内联文件:
https://transfer.sh/1ldau/test.txt-> https://transfer.sh/inline/1dau/test.txt
| 范围 | 描述 | 价值 | env |
|---|---|---|---|
| 听众 | 用于HTTP的端口(:80) | 听众 | |
| 配置文件 | 用于参考器的端口(:6060) | profile_listener | |
| 力量https | 重定向到https | 错误的 | force_https |
| TLS-Listener | 用于HTTPS的端口(:443) | tls_listener | |
| 仅限tls-listener | 标志仅启用TLS听众 | tls_listener_only | |
| TLS-Cert-File | 通往TLS证书的路径 | tls_cert_file | |
| TLS-PRIVATE-KEY | 通往TLS私钥的路径 | tls_private_key | |
| http-auth-user | 上传的基本HTTP Auth的用户 | http_auth_user | |
| http-auth-pass | 在上传时通过基本HTTP Auth | http_auth_pass | |
| http-auth-htpasswd | 上传时基本HTTP AUTH的HTPASSWD文件路径 | http_auth_htpasswd | |
| http-auth-ip-whitelist | 逗号分隔的IP列表允许上传而无需挑战HTTP Auth | http_auth_ip_whitelist | |
| IP-Whitelist | 逗号分隔的IPS列表允许连接到服务 | ip_whitelist | |
| IP-Blacklist | 逗号分隔的IPS列表不允许连接到服务 | ip_blacklist | |
| 临时路径 | 通往温度文件夹的路径 | 系统温度 | temp_path |
| 网络路径 | 通往静态Web文件的路径(用于开发或自定义前端) | Web_path | |
| 代理路径 | 当服务在代理后面运行时,路径前缀 | proxy_path | |
| 代理港 | 当服务在代理后面运行时,代理的港口 | proxy_port | |
| 电子邮件接口 | 通过电子邮件联系前端 | email_contact | |
| ga-key | Google Analytics(Analytics)的前端密钥 | ga_key | |
| 提供者 | 哪个存储提供商要使用 | (S3,Storj,Gdrive或Local) | |
| uservoice-key | 前端的用户语音键 | uservoice_key | |
| aws-access-key | AWS访问密钥 | AWS_ACCESS_KEY | |
| AWS秘密键 | AWS访问密钥 | aws_secret_key | |
| 桶 | AWS桶 | 桶 | |
| S3-端点 | 自定义S3端点。 | S3_ENDPOINT | |
| S3区 | S3桶的区域 | 欧盟-West-1 | S3_Region |
| S3-no-Multipart | 禁用S3 Multipart上传 | 错误的 | s3_no_multipart |
| S3派式风格 | 强迫路径样式的URL,Minio所需。 | 错误的 | s3_path_style |
| Storj-Access | 访问该项目 | storj_access | |
| Storj-Bucket | 在项目中使用的存储桶 | storj_bucket | |
| 基于 | 本地/GDRIVE提供商的路径存储 | 基于 | |
| gdrive-client-json-filepath | GDRIVE提供商的OAuth客户端JSON配置的路径 | gdrive_client_json_filepath | |
| gdrive-local-config-path | 存储本地传输的路径。SH配置缓存GDRIVE提供商 | gdrive_local_config_path | |
| gdrive-chunk大小 | gdrive上传的块大小必须低于可用内存(8 MB) | gdrive_chunk_size | |
| 让我们加入主持人 | 主机用于Lets加密证书(逗号分开) | 主持人 | |
| 日志 | 日志文件的路径 | 日志 | |
| CORS域 | 逗号分开的CORS域列表,将其设置为启用CORS | cors_domains | |
| Clamav-host | clamav功能的主机 | clamav_host | |
| 表演 - 克拉马夫·普雷斯卡岛 | Prescan通过Clamav功能上传的每个上传(Clamav-host必须是本地Clamd Unix插座) | percorm_clamav_prescan | |
| 费率限制 | 每分钟请求 | rate_limit | |
| Max-Upload-size | 最大上传尺寸为千字节 | max_upload_size | |
| 清除日 | 自动清除上传后的天数 | purge_days | |
| 吹扫间隔 | 时间间隔以运行自动清洗的时间(不适用于S3和Storj) | purge_interval | |
| 随机长度 | 上传路径的随机令牌的长度(删除路径的大小是两倍) | 6 | Random_token_length |
如果您想使用LETS加密证书使用TLS,请将Lets-Encrypt-Hosts设置为域,将TLS-Listener设置为:443并启用Force-HTTPS。
如果要使用自己的证书使用TLS,请将TLS-Listener设置为:443,Force-HTTPS,TLS-Cert-File和TLS-Provate-Key。
切换到GO111模块
go run main.go --provider=local --listener :8080 --temp-path=/tmp/ --basedir=/tmp/$ git clone [email protected]:dutchcoders/transfer.sh.git
$ cd transfer.sh
$ go build -o transfersh main.go为了轻松部署,我们创建了一个官方的Docker容器。有两个变体,只有用户运行该过程的不同之处。
默认一个将以root运行:
docker run --publish 8080:8080 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/用后缀-noroot标记的一个将使用5000作为UID和GID:
docker run --publish 8080:8080 dutchcoders/transfer.sh:latest-noroot --provider local --basedir /tmp/您也可以自己构建容器。这使您可以选择使用哪个UID/GID,例如使用NFS安装座时:
# Build arguments:
# * RUNAS: If empty, the container will run as root.
# Set this to anything to enable UID/GID selection.
# * PUID: UID of the process. Needs RUNAS != "". Defaults to 5000.
# * PGID: GID of the process. Needs RUNAS != "". Defaults to 5000.
docker build -t transfer.sh-noroot --build-arg RUNAS=doesntmatter --build-arg PUID=1337 --build-arg PGID=1338 . 对于使用AWS S3存储桶的使用情况,您只需要指定以下选项:
--provider s3AWS_ACCESS_KEY )AWS_SECRET_KEY )BUCKET )S3_REGION )如果指定S3区域,则无需设置端点URL,因为正确的端点将自动使用。
要使用自定义的非AWS S3提供商,您需要指定云提供商定义的端点。
要使用Storj网络作为存储提供商,您需要指定以下标志:
--provider storj您需要创建访问赠款(或从上行链路配置中复制它),并在准备工作中获得一个存储桶。
首先,请登录您的帐户,然后转到“访问赠款”菜单,然后在右上角启动向导。
输入您选择的访问授予名称,点击接下来并根据必要/首选限制它。之后继续在CLI或浏览器内继续进行。接下来,要求您使用用作加密密钥的密码。确保将其保存在安全的地方。没有它,您将失去解密文件的能力!
之后,您可以复制访问赠款,然后启动Travess.sh端点的启动。建议同时提供访问赠款和存储桶名作为ENV变量,以增强安全性。
例子:
export STORJ_BUCKET=<BUCKET NAME>
export STORJ_ACCESS=<ACCESS GRANT>
transfer.sh --provider storj
对于使用Google Drive的使用情况,您需要指定以下选项:
您需要从console.cloud.google.com创建OAuth客户端ID,下载文件,然后将其放入安全目录中。
go run main.go --provider gdrive --basedir /tmp/ --gdrive-client-json-filepath /[credential_dir] --gdrive-local-config-path [directory_to_save_config]
transfer () (if [ $# -eq 0 ] ; then printf " No arguments specified.nUsage:n transfer <file|directory>n ... | transfer <file_name>n " >&2 ; return 1 ; fi ; file_name= $( basename " $1 " ) ; if [ -t 0 ] ; then file= " $1 " ; if [ ! -e " $file " ] ; then echo " $file : No such file or directory " >&2 ; return 1 ; fi ; if [ -d " $file " ] ; then cd " $file " || return 1 ; file_name= " $file_name .zip " ; set -- zip -r -q - . ; else set -- cat " $file " ; fi ; else set -- cat ; fi ; url= $( " $@ " | curl --silent --show-error --progress-bar --upload-file " - " " https://transfer.sh/ $file_name " ) ; echo " $url " ; ) $ transfer hello.txt
transfer ()
{
local file
declare -a file_array
file_array=( " ${ @ } " )
if [[ " ${file_array[@]} " == " " || " ${1} " == " --help " || " ${1} " == " -h " ]]
then
echo " ${0} - Upload arbitrary files to " transfer.sh " . "
echo " "
echo " Usage: ${0} [options] [<file>]... "
echo " "
echo " OPTIONS: "
echo " -h, --help "
echo " show this message "
echo " "
echo " EXAMPLES: "
echo " Upload a single file from the current working directory: "
echo " ${0} " image.img " "
echo " "
echo " Upload multiple files from the current working directory: "
echo " ${0} " image.img " " image2.img " "
echo " "
echo " Upload a file from a different directory: "
echo " ${0} " /tmp/some_file " "
echo " "
echo " Upload all files from the current working directory. Be aware of the webserver's rate limiting!: "
echo " ${0} * "
echo " "
echo " Upload a single file from the current working directory and filter out the delete token and download link: "
echo " ${0} " image.img " | awk --field-separator= " : " '/Delete token:/ { print $ 2 } /Download link:/ { print $ 2 }' "
echo " "
echo " Show help text from " transfer.sh " : "
echo " curl --request GET " https://transfer.sh " "
return 0
else
for file in " ${file_array[@]} "
do
if [[ ! -f " ${file} " ]]
then
echo -e " e[01;31m' ${file} ' could not be found or is not a file.e[0m " >&2
return 1
fi
done
unset file
fi
local upload_files
local curl_output
local awk_output
du -c -k -L " ${file_array[@]} " >&2
# be compatible with "bash"
if [[ " ${ZSH_NAME} " == " zsh " ]]
then
read $' upload_files? e [01;31mDo you really want to upload the above files ( ' " ${ # file_array[@]} " $' ) to "transfer.sh"? (Y/n): e [0m '
elif [[ " ${BASH} " == * " bash " * ]]
then
read -p $' e [01;31mDo you really want to upload the above files ( ' " ${ # file_array[@]} " $' ) to "transfer.sh"? (Y/n): e [0m ' upload_files
fi
case " ${upload_files :- y} " in
" y " | " Y " )
# for the sake of the progress bar, execute "curl" for each file.
# the parameters "--include" and "--form" will suppress the progress bar.
for file in " ${file_array[@]} "
do
# show delete link and filter out the delete token from the response header after upload.
# it is important to save "curl's" "stdout" via a subshell to a variable or redirect it to another command,
# which just redirects to "stdout" in order to have a sane output afterwards.
# the progress bar is redirected to "stderr" and is only displayed,
# if "stdout" is redirected to something; e.g. ">/dev/null", "tee /dev/null" or "| <some_command>".
# the response header is redirected to "stdout", so redirecting "stdout" to "/dev/null" does not make any sense.
# redirecting "curl's" "stderr" to "stdout" ("2>&1") will suppress the progress bar.
curl_output= $( curl --request PUT --progress-bar --dump-header - --upload-file " ${file} " " https://transfer.sh/ " )
awk_output= $( awk
' gsub("r", "", $0) && tolower($1) ~ /x-url-delete/
{
delete_link=$2;
print "Delete command: curl --request DELETE " """delete_link""";
gsub(".*/", "", delete_link);
delete_token=delete_link;
print "Delete token: " delete_token;
}
END{
print "Download link: " $0;
} ' <<< " ${curl_output} " )
# return the results via "stdout", "awk" does not do this for some reason.
echo -e " ${awk_output} n "
# avoid rate limiting as much as possible; nginx: too many requests.
if (( ${ # file_array[@]} > 4 ))
then
sleep 5
fi
done
;;
" n " | " N " )
return 1
;;
* )
echo -e " e[01;31mWrong input: ' ${upload_files} '.e[0m " >&2
return 1
esac
}$ ls -lh
total 20M
-rw-r--r-- 1 < some_username > < some_username > 10M Apr 4 21:08 image.img
-rw-r--r-- 1 < some_username > < some_username > 10M Apr 4 21:08 image2.img
$ transfer image *
10240K image2.img
10240K image.img
20480K total
Do you really want to upload the above files (2) to " transfer.sh " ? (Y/n):
# ####################################################################################################################################################################################################################################### 100.0%
Delete command: curl --request DELETE " https://transfer.sh/wJw9pz/image2.img/mSctGx7pYCId "
Delete token: mSctGx7pYCId
Download link: https://transfer.sh/wJw9pz/image2.img
# ####################################################################################################################################################################################################################################### 100.0%
Delete command: curl --request DELETE " https://transfer.sh/ljJc5I/image.img/nw7qaoiKUwCU "
Delete token: nw7qaoiKUwCU
Download link: https://transfer.sh/ljJc5I/image.img
$ transfer " image.img " | awk --field-separator= " : " ' /Delete token:/ { print $2 } /Download link:/ { print $2 } '
10240K image.img
10240K total
Do you really want to upload the above files (1) to " transfer.sh " ? (Y/n):
# ####################################################################################################################################################################################################################################### 100.0%
tauN5dE3fWJe
https://transfer.sh/MYkuqn/image.img欢迎捐款。
Remco Verhoef
Uvis Grinfelds
安德里亚·斯帕卡(Andrea Spacca)
Stefan Benten
代码和文档版权2011-2018 Remco Verhoef。代码和文档版权2018-2020 Andrea Spacca。代码和文档版权2020-安德里亚·斯帕卡(Andrea Spacca)和斯特凡·本顿(Stefan Benten)。
根据MIT许可发布的代码。