
從命令行共享簡單快速的文件。此代碼包含服務器,其中包含創建自己實例所需的一切。
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許可發布的代碼。