
Berbagi file yang mudah dan cepat dari baris perintah. Kode ini berisi server dengan semua yang Anda butuhkan untuk membuat instance Anda sendiri.
Transfer.sh saat ini mendukung S3 (Amazon S3), GDRive (Google Drive), penyedia Storj (Storj), dan Sistem File Lokal (Lokal).
@stefanbenten kebetulan menjadi pemelihara repositori ini dan orang yang meng -host instalasi publik yang terkenal dari perangkat lunak dalam repo.
Keduanya tidak terkait, dan repo itu bukan tempat untuk mengarahkan permintaan dan masalah untuk instalasi pubblic.
Tidak ada instalasi publik pihak ketiga dari perangkat lunak dalam repo yang akan diiklankan atau disebutkan dalam repo itu sendiri, untuk alasan keamanan.
Posisi resmi saya, @aspacca, sebagai pemelihara repo, adalah bahwa jika Anda ingin menggunakan perangkat lunak, Anda harus meng -host instalasi Anda sendiri.
$ 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 digunakan untuk meminta penghapusan file dan dikembalikan sebagai header respons.
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.txtLihat contoh penggunaan yang baik di contoh.md
Buat tautan unduhan langsung:
https://transfer.sh/1ldau/test.txt -> https://transfer.sh/get/1ldau/test.txt
File inline:
https://transfer.sh/1ldau/test.txt -> https://transfer.sh/inline/1ldau/test.txt
| Parameter | Keterangan | Nilai | Env |
|---|---|---|---|
| pendengar | Port untuk digunakan untuk http (: 80) | PENDENGAR | |
| pendengar profil | Port untuk digunakan untuk Profiler (: 6060) | Profile_listener | |
| force-https | Redirect ke https | PALSU | Force_https |
| TLS-Listener | Port untuk digunakan untuk https (: 443) | Tls_listener | |
| TLS-Listener saja | bendera untuk memungkinkan pendengar TLS saja | Tls_listener_only | |
| TLS-CERT-File | Jalur ke sertifikat TLS | Tls_cert_file | |
| TLS-Private-Key | jalur ke kunci pribadi TLS | Tls_private_key | |
| http-auth-user | Pengguna untuk Auth HTTP Dasar Saat Mengunggah | Http_auth_user | |
| http-auth-pass | Lulus untuk HTTP Auth dasar pada unggahan | Http_auth_pass | |
| http-auth-htpasswd | HTPASSWD File Path untuk HTTP Auth Dasar di Unggah | Http_auth_htpasswd | |
| http-auth-ip-whitelist | Daftar IP yang terpisah koma diizinkan untuk mengunggah tanpa ditantang oleh auth http | Http_auth_ip_whitelist | |
| IP-Whitelist | Daftar IP yang terpisah koma diizinkan untuk terhubung ke layanan | Ip_whitelist | |
| IP-blacklist | Daftar IP yang terpisah koma tidak diizinkan untuk terhubung ke layanan | Ip_blacklist | |
| Temp-path | Path to Temp Folder | Temp sistem | Temp_path |
| jalur web | jalur ke file web statis (untuk pengembangan atau ujung depan khusus) | Web_path | |
| jalur proxy | awalan jalur saat layanan dijalankan di belakang proxy | Proxy_path | |
| proxy-port | port proxy saat layanan dijalankan di belakang proxy | Proxy_port | |
| Kontak email | Kontak email untuk ujung depan | Email_contact | |
| Ga-key | Kunci Google Analytics untuk ujung depan | Ga_key | |
| penyedia | Penyedia penyimpanan mana yang akan digunakan | (S3, Storj, Gdrive atau Lokal) | |
| Uservoice-Key | Kunci suara pengguna untuk ujung depan | Uservoice_key | |
| AWS-Access-Key | Kunci Akses AWS | AWS_ACCESS_KEY | |
| AWS-Sas-Secret-Key | Kunci Akses AWS | AWS_SECRET_KEY | |
| keranjang | AWS Bucket | KERANJANG | |
| s3-endpoint | Titik Akhir S3 Kustom. | S3_endpoint | |
| S3-Region | wilayah ember S3 | UE-West-1 | S3_region |
| S3-no-multipart | menonaktifkan unggahan multipart S3 | PALSU | S3_NO_MULTIPART |
| S3-Path-style | URL Gaya Path Pasukan, Diperlukan untuk Minio. | PALSU | S3_path_style |
| Storj-Access | Akses untuk Proyek | STORJ_ACCESS | |
| Storj-Bucket | Ember untuk digunakan dalam proyek | STORJ_BUCKET | |
| berbasis | penyimpanan jalur untuk penyedia lokal/gdrive | Berbasis | |
| gdrive-client-json-filepath | Path to OAuth Client JSON Config untuk penyedia gdrive | Gdrive_client_json_filepath | |
| Gdrive-Local-Config-Path | jalur untuk menyimpan cache konfigurasi transfer.sh lokal untuk penyedia gdrive | Gdrive_local_config_path | |
| ukuran gdrive-chunk | Ukuran chunk untuk unggahan gdrive di megabytes, harus lebih rendah dari memori yang tersedia (8 MB) | Gdrive_chunk_size | |
| mari-encrypt-hosts | Host yang akan digunakan untuk Lets Encrypt Certificates (Comma Disperated) | Tuan rumah | |
| log | Path to Log File | Log | |
| domain CORS | Daftar domain yang terpisah koma untuk COR, mengaturnya memungkinkan CORS | Cors_domains | |
| HOST CLAMAV | host untuk fitur clamav | Clamav_host | |
| Performa-Prescan | prescan setiap unggahan melalui fitur clamav (clamav-host harus berupa soket unix clangd lokal) | Perform_clamav_prescan | |
| batas batas | permintaan per menit | Rate_limit | |
| Ukuran Max-Upload | Ukuran unggahan maks dalam kilobytes | Max_upload_size | |
| Hari Pembersihan | Jumlah hari setelah unggahan dibersihkan secara otomatis | Purge_days | |
| Purge-interval | Interval dalam jam untuk menjalankan pembersihan otomatis (tidak berlaku untuk S3 dan Storj) | Purge_interval | |
| panjang acak-acak | Panjang token acak untuk jalur unggahan (gandakan ukuran untuk jalur hapus) | 6 | Acak_token_length |
Jika Anda ingin menggunakan TLS menggunakan Lets Encrypt Certificate, atur mari-encrypt-host ke domain Anda, atur TLS-Listener ke: 443 dan aktifkan force-https.
Jika Anda ingin menggunakan TLS menggunakan sertifikat Anda sendiri, atur TLS-Listener ke: 443, Force-HTTPS, TLS-CERT-FILE dan TLS-Private-Key.
Beralih ke 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.goUntuk penempatan yang mudah, kami telah membuat wadah Docker resmi. Ada dua varian, hanya berbeda dengan mana pengguna menjalankan proses.
Yang default akan berjalan sebagai root :
docker run --publish 8080:8080 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/ Yang ditandai dengan akhiran -noroot akan menggunakan 5000 sebagai uid dan gid:
docker run --publish 8080:8080 dutchcoders/transfer.sh:latest-noroot --provider local --basedir /tmp/Anda juga dapat membangun wadah sendiri. Ini memungkinkan Anda untuk memilih UID/GID mana yang akan digunakan, misalnya saat menggunakan mount 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 . Untuk penggunaan dengan ember AWS S3, Anda hanya perlu menentukan opsi berikut:
--provider s3AWS_ACCESS_KEY )AWS_SECRET_KEY )BUCKET lingkungan)S3_REGION )Jika Anda menentukan S3-Region, Anda tidak perlu mengatur URL titik akhir karena titik akhir yang benar akan digunakan secara otomatis.
Untuk menggunakan penyedia S3 Non-AWS khusus, Anda perlu menentukan titik akhir sebagaimana didefinisikan dari penyedia cloud Anda.
Untuk menggunakan jaringan Storj sebagai penyedia penyimpanan, Anda perlu menentukan bendera berikut:
--provider storj ProviderAnda perlu membuat hibah akses (atau menyalinnya dari konfigurasi uplink) dan ember dalam persiapan.
Untuk memulai, masuk ke akun Anda dan pergi ke menu hibah akses dan mulai wizard di kanan atas.
Masukkan nama hibah akses Anda pilihan, tekan berikutnya dan batasi sesuai kebutuhan/lebih disukai. Setelah itu, lanjutkan baik di CLI atau di dalam browser. Selanjutnya, Anda akan diminta frasa sandi yang digunakan sebagai kunci enkripsi. Pastikan untuk menyimpannya di tempat yang aman. Tanpa itu, Anda akan kehilangan kemampuan untuk mendekripsi file Anda!
Setelah itu, Anda dapat menyalin hibah akses dan kemudian memulai startup dari titik akhir transfer.sh. Disarankan untuk memberikan hibah akses dan nama ember sebagai variabel Env untuk keamanan yang ditingkatkan.
Contoh:
export STORJ_BUCKET=<BUCKET NAME>
export STORJ_ACCESS=<ACCESS GRANT>
transfer.sh --provider storj
Untuk penggunaan dengan Google Drive, Anda perlu menentukan opsi berikut:
Anda perlu membuat ID klien OAuth dari console.cloud.google.com, unduh file, dan masukkan ke direktori yang aman.
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.imgKontribusi dipersilakan.
Remco Verhoef
Uvis Grinfelds
Andrea Spacca
Stefan Benten
Kode dan Dokumentasi Hak Cipta 2011-2018 Remco Verhoef. Kode dan Dokumentasi Hak Cipta 2018-2020 Andrea Spacca. Kode dan Dokumentasi Hak Cipta 2020- Andrea Spacca dan Stefan Benten.
Kode yang dirilis di bawah lisensi MIT.