
การแชร์ไฟล์ที่ง่ายและรวดเร็วจากบรรทัดคำสั่ง รหัสนี้มีเซิร์ฟเวอร์พร้อมทุกสิ่งที่คุณต้องการเพื่อสร้างอินสแตนซ์ของคุณเอง
ปัจจุบัน transfer.sh รองรับ S3 (Amazon S3), GDRIVE (Google Drive), ผู้ให้บริการ StorJ (StorJ) และระบบไฟล์ในท้องถิ่น (ท้องถิ่น)
@stefanbenten เป็นผู้ดูแลพื้นที่เก็บข้อมูลนี้ และ บุคคลที่โฮสต์การติดตั้งซอฟต์แวร์สาธารณะที่รู้จักกันดีใน Repo
ทั้งสองยังไม่เกี่ยวข้องและ repo ไม่ใช่สถานที่สำหรับการร้องขอโดยตรงและปัญหาสำหรับการติดตั้ง pubblic ใด ๆ
ไม่มีการติดตั้งซอฟต์แวร์สาธารณะของบุคคลที่สามใน Repo จะได้รับการโฆษณาหรือกล่าวถึงใน Repo ด้วยเหตุผลด้านความปลอดภัย
ตำแหน่งอย่างเป็นทางการของฉัน @aspacca ในฐานะผู้ดูแล Repo คือถ้าคุณต้องการใช้ซอฟต์แวร์คุณควรโฮสต์การติดตั้งของคุณเอง
$ 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/1ldau/test.txt
| พารามิเตอร์ | คำอธิบาย | ค่า | env |
|---|---|---|---|
| ผู้ฟัง | พอร์ตที่จะใช้สำหรับ http (: 80) | ผู้ฟัง | |
| ผู้ฟังโปรไฟล์ | พอร์ตเพื่อใช้สำหรับ Profiler (: 6060) | profile_listener | |
| แรง -Https | เปลี่ยนเส้นทางไปยัง https | เท็จ | force_https |
| tls-listener | พอร์ตเพื่อใช้สำหรับ https (: 443) | tls_listener | |
| tls-listener-only | ตั้งค่าสถานะเพื่อเปิดใช้งานผู้ฟัง TLS เท่านั้น | tls_listener_only | |
| tls-cert-file | Path to 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 | พา ธ ไฟล์ htpasswd สำหรับ http auth พื้นฐานในการอัปโหลด | http_auth_htpasswd | |
| http-auth-ip-Whitelist | รายการ IPS ที่แยกจากกันของจุลภาคได้รับอนุญาตให้อัปโหลดโดยไม่ถูกท้าทาย HTTP Auth | http_auth_ip_whitelist | |
| IP-Whitelist | เครื่องหมายจุลภาคที่แยก IPS ได้รับอนุญาตให้เชื่อมต่อกับบริการ | ip_whitelist | |
| IP-Blacklist | เครื่องหมายจุลภาคที่คั่นด้วย IPS ไม่ได้รับอนุญาตให้เชื่อมต่อกับบริการ | ip_blacklist | |
| อุณหภูมิ | Path to Temp Folder | อุณหภูมิระบบ | temp_path |
| เส้นทางเว็บ | Path ไปยังไฟล์เว็บแบบคงที่ (สำหรับการพัฒนาหรือปลายด้านหน้าที่กำหนดเอง) | web_path | |
| พร็อกซีพา ธ | คำนำหน้าเส้นทางเมื่อบริการทำงานอยู่เบื้องหลังพร็อกซี | Proxy_Path | |
| พอร์ตพอร์ต | พอร์ตของพร็อกซีเมื่อบริการทำงานด้านหลังพร็อกซี | Proxy_port | |
| ติดต่ออีเมล | ติดต่ออีเมลสำหรับส่วนหน้า | email_contact | |
| ga-key | คีย์ Google Analytics สำหรับส่วนหน้า | ga_key | |
| ผู้ให้บริการ | ผู้ให้บริการจัดเก็บข้อมูลใดที่จะใช้ | (S3, Storj, Gdrive หรือท้องถิ่น) | |
| uservoice-key | คีย์เสียงของผู้ใช้สำหรับส่วนหน้า | uservoice_key | |
| Aws-Access-Key | AWS Access Key | aws_access_key | |
| aws-secret-key | AWS Access Key | aws_secret_key | |
| ถัง | Bucket AWS | ถัง | |
| S3-endpoint | จุดสิ้นสุด S3 แบบกำหนดเอง | s3_endpoint | |
| S3-Region | ภูมิภาคของถัง S3 | EU-WEST-1 | S3_REGION |
| S3-no-multipart | ปิดใช้งานการอัปโหลด S3 Multipart | เท็จ | S3_NO_MULTIPART |
| สไตล์ S3-path | URL สไตล์ Path Path จำเป็นสำหรับ MINIO | เท็จ | s3_path_style |
| storj-access | เข้าถึงโครงการ | storj_access | |
| Storj-bucket | ถังที่จะใช้ภายในโครงการ | storj_bucket | |
| คน | ที่เก็บพา ธ สำหรับผู้ให้บริการท้องถิ่น/GDrive | คน | |
| gdrive-client-json-filepath | PATH TO OAUTH Client JSON Config สำหรับผู้ให้บริการ GDRIVE | gdrive_client_json_filepath | |
| gdrive-local-config-path | Path to Store Local Transfer.sh Config Cache สำหรับผู้ให้บริการ GDRIVE | gdrive_local_config_path | |
| Gdrive-chunk-size | ขนาดก้อนสำหรับการอัปโหลด GDRIVE ในเมกะไบต์ต้องต่ำกว่าหน่วยความจำที่มีอยู่ (8 MB) | gdrive_chunk_size | |
| ปล่อยให้เป็นเจ้าภาพ | โฮสต์ที่จะใช้สำหรับ Lets Encrypt Certificates (Comma Seperated) | เจ้าภาพ | |
| บันทึก | พา ธ ไปบันทึกไฟล์ | บันทึก | |
| Cors-domains | เครื่องหมายจุลภาคแยกโดเมนสำหรับ CORS การตั้งค่าเปิดใช้งาน CORS | cors_domains | |
| เจ้าชู้ | โฮสต์สำหรับคุณสมบัติ Clamav | Clamav_host | |
| ดำเนินการ | prescan ทุกการอัปโหลดผ่านคุณสมบัติ Clamav (Clamav-Host ต้องเป็นซ็อกเก็ต UNIX ในท้องถิ่น) | perform_clamav_prescan | |
| ขีด จำกัด อัตรา | ขอต่อนาที | rate_limit | |
| ขนาดสูงสุด | ขนาดอัพโหลดสูงสุดเป็นกิโลไบต์ | max_upload_size | |
| ล้างวัน | จำนวนวันหลังจากการอัปโหลดจะถูกกำจัดโดยอัตโนมัติ | Purge_days | |
| การขัด | ช่วงเวลาเป็นชั่วโมงเพื่อเรียกใช้การล้างอัตโนมัติ (ไม่สามารถใช้ได้กับ S3 และ StorJ) | Purge_interval | |
| ความยาวแบบสุ่ม | ความยาวของโทเค็นสุ่มสำหรับเส้นทางการอัปโหลด (เพิ่มขนาดสองเท่าสำหรับเส้นทางลบ) | 6 | แบบสุ่ม _token_length |
หากคุณต้องการใช้ TLS โดยใช้ Lets Encrypt Certificates ให้ตั้งค่าการเข้ารหัสโฮสต์ให้กับโดเมนของคุณให้ตั้งค่า TLS-listener เป็น: 443 และเปิดใช้งาน Force-HTTPS
หากคุณต้องการใช้ TLS โดยใช้ใบรับรองของคุณเองให้ตั้งค่า TLS-Listener เป็น: 443, Force-HTTPS, TLS-Cert-file และ TLS-Private-Key
เปลี่ยนเป็น go111module
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 Mounts:
# 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 . สำหรับการใช้งานกับ Bucket AWS S3 คุณเพียงแค่ต้องระบุตัวเลือกต่อไปนี้:
--provider s3AWS_ACCESS_KEY )AWS_SECRET_KEY )BUCKET สภาพแวดล้อม)S3_REGION )หากคุณระบุภูมิภาค S3 คุณไม่จำเป็นต้องตั้งค่า URL ปลายทางเนื่องจากจุดสิ้นสุดที่ถูกต้องจะใช้โดยอัตโนมัติ
ในการใช้ผู้ให้บริการที่ไม่ใช่ AWS S3 แบบกำหนดเองคุณต้องระบุจุดสิ้นสุดตามที่กำหนดจากผู้ให้บริการคลาวด์ของคุณ
ในการใช้เครือข่าย StorJ เป็นผู้ให้บริการจัดเก็บคุณต้องระบุสถานะต่อไปนี้:
--provider storjคุณต้องสร้างสิทธิ์การเข้าถึง (หรือคัดลอกจากการกำหนดค่าอัปลิงค์) และถังเพื่อเตรียมการ
ในการเริ่มต้นให้เข้าสู่ระบบบัญชีของคุณและไปที่เมนู Access Grant และเริ่มต้นตัวช่วยสร้างที่ด้านบนขวา
ป้อนชื่อการเลือกสิทธิ์การเข้าถึงของคุณกด ต่อไป และ จำกัด ตามความจำเป็น/ต้องการ หลังจากนั้นดำเนินการต่อใน CLI หรือภายในเบราว์เซอร์ ต่อไปคุณจะถูกขอให้ใช้รหัสผ่านที่ใช้เป็นคีย์การเข้ารหัส ตรวจสอบให้แน่ใจว่าได้บันทึกไว้ในที่ปลอดภัย หากไม่มีมันคุณจะสูญเสียความสามารถในการถอดรหัสไฟล์ของคุณ!
หลังจากนั้นคุณสามารถคัดลอกสิทธิ์การเข้าถึงจากนั้นเริ่มต้นการเริ่มต้นของจุดสิ้นสุด transfer.sh ขอแนะนำให้ให้ทั้งสิทธิ์การเข้าถึงและชื่อถังเป็นตัวแปร ENV สำหรับการรักษาความปลอดภัยที่เพิ่มขึ้น
ตัวอย่าง:
export STORJ_BUCKET=<BUCKET NAME>
export STORJ_ACCESS=<ACCESS GRANT>
transfer.sh --provider storj
สำหรับการใช้งานกับ Google Drive คุณต้องระบุตัวเลือกต่อไปนี้:
คุณต้องสร้างรหัสไคลเอนต์ OAuth จาก console.cloud.google.com ดาวน์โหลดไฟล์และวางลงในไดเรกทอรีที่ปลอดภัย
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