Skrip Bash yang menggunakan curl untuk mengirim file dan folder ke folder nextcloud/owncloud yang dibagikan secara publik.
Logikanya adalah
cloudsend <file/folder/glob> <PublicURL>
The Origins ada di sini, Terima kasih untuk semua orang yang berkontribusi pada GIST asli
Periksa juga aplikasi cloudmanager saya untuk klien webdav nextcloud/owncloud lengkap.
Cloudsend v2 mengubah cara kerja penguraian kata sandi.
Cloudsend 0.xx menggunakan parameter -p untuk kata sandi Lingkungan (diubah menjadi -e di v2+).
Harap gunakan SALAH SATU -e ATAU -p , tetapi jangan keduanya. Yang terakhir dipanggil akan digunakan.
Env Pass > Setel variabel CLOUDSEND_PASSWORD='MySecretPass' dan gunakan opsi -e
Param Pass > Kirim kata sandi sebagai parameter dengan -p <password>
Anda dapat menggunakan input globbing (wildcard) dengan mengatur opsi -g .
Ini akan mengabaikan pemeriksaan file masukan dan meneruskan glob ke curl untuk digunakan.
Anda TIDAK HARUS mengganti nama file saat melakukan globbing, nama file masukan akan digunakan.
Anda TIDAK BOLEH mengirim folder saat melakukan globbing, hanya file yang diperbolehkan.
Contoh gumpalan:
'{file1.txt,file2.txt,file3.txt}'
'img[1-100].png'
Informasi lebih lanjut tentang globbing
https://github.com/tavinus/cloudsend.sh/wiki/Input-Globbing
Anda dapat mengirim konten yang disalurkan dengan menggunakan - atau . sebagai nama file masukan (spesifikasi curl) .
Anda HARUS menetapkan nama file tujuan untuk menggunakan stdin sebagai input ( -r <name> ).
Dari manual curl :
Gunakan nama file - (satu tanda hubung) untuk menggunakan stdin alih-alih file tertentu.
Sebagai alternatif, nama file . (satu periode) dapat ditentukan sebagai pengganti - untuk digunakan
stdin dalam mode non-pemblokiran untuk memungkinkan pembacaan output server saat stdin sedang diunggah.
Dari v2.2.0 cloudsend.sh dapat mengirim folder. Ini akan melintasi pohon folder, buat
setiap folder dan mengirim setiap file. Cukup gunakan jalur folder sebagai input.
Ini mengirimkan setiap FILE di folder shell saat ini.
ubah ./ pertama untuk mengubah folder input ( mis. '/home/myname/myfolder' )
-maxdepth 1 hanya akan membaca folder saat ini, semakin banyak level yang masuk lebih dalam, menekan semua level
temukan ./ -max depth 1 -type f -exec ./cloudsend.sh {} https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG -p Kata Sandi Anda ; Ini mengirimkan setiap FILE di dalam /home/myname/myfolder , termasuk SEMUA subfolder.
temukan /home/myname/myfolder -type f -exec ./cloudsend.sh {} https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG -p kata sandi Anda;Ini mengirimkan tarball gzip dari folder shell saat ini.
tar cf - "$(pwd)" | gzip -9 -c | ./cloudsend.sh - 'https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG' -r myfolder.tar.gz
Ini mengirimkan tarball gzip /home/myname/myfolder .
tar cf - /home/namasaya/folder saya | gzip -9 -c | ./cloudsend.sh - 'https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG' -r myfolder.tar.gz
Ini mengirimkan file zip rekursif /home/myname/myfolder .
zip -q -r -9 - /home/namasaya/folder saya | ./cloudsend.sh - 'https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG' -r myfolder.zip
Sejak versi 2.3.2 Anda dapat membuat folder di server jauh dengan parameter -C|--mkdir . Ini bisa berupa satu folder atau satu pohon.
Lewatkan saja folder yang akan dibuat seolah-olah itu adalah file yang sedang dikirim.
$ ./cloudsend.sh -C -p MyPassword 'A Folder' "https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY" Tavinus Cloud Sender v2.3.5 > Color mode OFF > Using password from Parameter > Makedir mode is ON ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ CREATING FOLDERS ON TARGET ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ A Folder > OK (created) ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ MAIN TARGET DOWNLOAD URL ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ Download URL: > https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY/download?path=/A Folder https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY/download?path=%2fA%20Folder Access URL: > https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY?path=/A Folder https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY?path=%2fA%20Folder ‗‗‗‗‗‗‗‗‗ SUMMARY ‾‾‾‾‾‾‾‾‾ Curl : NO Errors CurlExit : 0 WebDav : NO Errors Status : Makedir Completed Root : / Base : / Full : / Target : A Folder Type : Directory
Sejak versi 2.3.1 Anda dapat menghapus file dan folder di server jauh.
Cukup gunakan opsi -D|--delete dan teruskan file/folder yang akan dihapus seolah-olah itu adalah file yang sedang dikirim.
Contoh ini menghapus A Folder dari server jauh dengan semua subfolder dan filenya.
$ ./cloudsend.sh -D -p MyPassword 'A Folder' "https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY" Tavinus Cloud Sender v2.3.5 > Using password from Parameter > Delete mode is ON ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ DELETING TARGET ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ A Folder > OK (deleted) ‗‗‗‗‗‗‗‗‗ SUMMARY ‾‾‾‾‾‾‾‾‾ Curl : NO Errors CurlExit : 0 WebDav : NO Errors Status : Delete Completed Root : / Base : / Full : / Target : A Folder Type : Unknown
Sejak versi 2.3.2 Anda dapat menetapkan folder target untuk operasi jarak jauh dengan parameter -T|--target . Ini bisa berupa satu folder atau satu pohon.
Pohon target akan dibuat sebelum menjalankan operasi, kecuali Anda menjalankan perintah hapus.
Semua perintah akan menggunakan folder target sebagai folder dasar (menghapus, mengirim, membuat folder, dll).
$ ./cloudsend.sh -p MyPassword -T 'A Folder/ A Subfolder' ./README.md "https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY" Tavinus Cloud Sender v2.3.5 > Using password from Parameter > Base Target folder set to: "/A Folder/ A Subfolder" ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ CREATING BASE TARGET FOLDERS ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ A Folder > OK (created) A Folder/ A Subfolder > OK (created) ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ SENDING SINGLE FILE ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ README.md > ######################################################################### 100.0% ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ MAIN TARGET DOWNLOAD URL ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ Download URL: > https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY/download?path=A Folder/ A Subfolder&files=README.md https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY/download?path=A%20Folder%2f%20A%20Subfolder&files=README.md Access URL: > https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY?path=A Folder/ A Subfolder&files=README.md https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY?path=A%20Folder%2f%20A%20Subfolder&files=README.md ‗‗‗‗‗‗‗‗‗ SUMMARY ‾‾‾‾‾‾‾‾‾ Curl : NO Errors CurlExit : 0 WebDav : NO Errors Status : Send Completed Root : / Base : /A Folder/ A Subfolder Full : /A Folder/ A Subfolder Target : README.md Type : File
Cloudsend juga mendukung pembacaan folder root dari URL (jika URL tertaut ke folder).
Cloudsend TIDAK akan mencoba membuat folder ini, folder ini harus sudah ada, tetapi akan menggunakannya sebagai folder root dasar untuk semuanya, termasuk pengaturan base --target .
Tautan dengan folder memiliki sintaks https://cloud.mydomain.tld/index.php/s/H2Q3RHXZ4f974sY?path=my root .
?path=my root itu mendefinisikan 'my root' sebagai folder target root.
Dalam contoh ini 'root saya' sudah ada di server, jika tidak, kita akan mendapatkan kesalahan
$ ./cloudsend.sh -p MyPass -T 'A Folder/A Subfolder' "../folder 1" "https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY?path=my root" Tavinus Cloud Sender v2.3.6 > Using password from Parameter > Base Target folder set to: "/A Folder/A Subfolder" > Root Target folder set from URL: "my root" ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ CREATING BASE TARGET FOLDERS ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ A Folder > OK (created) A Folder/A Subfolder > OK (created) ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ CREATING FOLDER TREE AT DESTINATION ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ folder 1 > OK (created) folder 1/folder 1-a > OK (created) folder 1/folder 1-a/folder 1 a 1 > OK (created) folder 1/folder 1-b > OK (created) ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ SENDING ALL FILES FROM FOLDER TREE ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ folder 1/file 1.txt > ######################################################################### 100.0% folder 1/file 2.txt > ######################################################################### 100.0% folder 1/file 3.txt > ######################################################################### 100.0% folder 1/folder 1-a/file 2 3.txt > ######################################################################### 100.0% folder 1/folder 1-a/folder 1 a 1/file 6.txt > ######################################################################### 100.0% folder 1/folder 1-b/file 5.txt > ######################################################################### 100.0% ‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗ MAIN TARGET DOWNLOAD URL ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ Download URL: > https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY/download?path=my root/A Folder/A Subfolder/folder 1 https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY/download?path=my%20root%2fA%20Folder%2fA%20Subfolder%2ffolder%201 Access URL: > https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY?path=my root/A Folder/A Subfolder/folder 1 https://cloud.mydomain.tld/index.php/s/H4Q3RHXZ4e974PY?path=my%20root%2fA%20Folder%2fA%20Subfolder%2ffolder%201 ‗‗‗‗‗‗‗‗‗ SUMMARY ‾‾‾‾‾‾‾‾‾ Curl : NO Errors CurlExit : 0 WebDav : NO Errors Status : Send Completed Root : /my root Base : /A Folder/A Subfolder Full : /my root/A Folder/A Subfolder Target : folder 1 Type : Directory
$ ./cloudsend --help
Tavinus Cloud Sender v2.3.8
Parameters:
-h | --help Print this help and exits
-q | --quiet Disables verbose messages
-V | --version Prints version and exits
-N | --no-color Disables colored output
-D | --delete Delete file/folder in remote share
-T | --target <dir> Rebase work into a target folder (instead of root)
-C | --mkdir Create a directory tree in the remote share
-r | --rename <file.xxx> Change the destination file name
-g | --glob Disable input file checking to use curl globs
-k | --insecure Uses curl with -k option (https insecure)
-A | --user-agent Specify user agent to use with curl -A option
-E | --referer Specify referer to use with curl -e option
-l | --limit-rate Uses curl limit-rate (eg 100k, 1M)
-a | --abort-on-errors Aborts on Webdav response errors
-p | --password <pass> Uses <pass> as shared folder password
-e | --envpass Uses env var $CLOUDSEND_PASSWORD as share password
You can 'export CLOUDSEND_PASSWORD' at your system, or set it at the call
Please remeber to also call -e to use the password set
Use:
./cloudsend.sh [options] <inputPath> <folderLink>
CLOUDSEND_PASSWORD='MySecretPass' ./cloudsend.sh -e [options] <inputPath> <folderLink>
Passwords:
Cloudsend 2 changed the way password works
Cloudsend 0.x.x used the '-p' parameter for the Environment password (changed to -e in v2+)
Please use EITHER -e OR -p, but not both. The last to be called will be used
Env Pass > Set the variable CLOUDSEND_PASSWORD='MySecretPass' and use the option '-e'
Param Pass > Send the password as a parameter with '-p <password>'
Folders:
Cloudsend 2.2.0 introduces folder tree sending. Just use a directory as <inputPath>.
It will traverse all files and folders, create the needed folders and send all files.
Each folder creation and file sending will require a curl call.
Target Folder:
Cloudsend 2.3.2 introduces the target folder setting. It will create the folder in the remote
host and send all files and folders into it. It also works as a base folder for the other operations
like deletion and folder creation. Accepts nested folders.
./cloudsend.sh -T 'f1/f2/f3' -p myPass 'folder|file' 'https://cloud.domain/index.php/s/vbi2za9esfrgvXC'
Create Folder:
Available since version 2.3.2. Just pass the folder name to be created as if it was the
file/folder being sent and add the -C | --mkdir parameter. Runs recursively.
./cloudsend.sh -C -p myPass 'new folder/new2' 'https://cloud.domain/index.php/s/vbi2za9esfrgvXC'
Delete:
Available since version 2.3.1. Just pass the file/folder to be deleted as if it was the
file/folder being sent and add the -D | --delete parameter.
./cloudsend.sh -D -p myPass 'folder/file' 'https://cloud.domain/index.php/s/vbi2za9esfrgvXC'
Input Globbing:
You can use input globbing (wildcards) by setting the -g option
This will ignore input file checking and pass the glob to curl to be used
You MUST NOT rename files when globbing, input file names will be used
You MUST NOT send folders when globbing, only files are allowed
Glob examples: '{file1.txt,file2.txt,file3.txt}'
'img[1-100].png'
Send from stdin (pipe):
You can send piped content by using - or . as the input file name (curl specs)
You MUST set a destination file name to use stdin as input (-r <name>)
Use the file name '-' (a single dash) to use stdin instead of a given file
Alternately, the file name '.' (a single period) may be specified instead of '-' to use
stdin in non-blocking mode to allow reading server output while stdin is being uploaded
Examples:
CLOUDSEND_PASSWORD='MySecretPass' ./cloudsend.sh -e './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
./cloudsend.sh './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
./cloudsend.sh 'my Folder' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
./cloudsend.sh -r 'RenamedFile.txt' './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
./cloudsend.sh --limit-rate 200K -p 'MySecretPass' './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
./cloudsend.sh -p 'MySecretPass' -r 'RenamedFile.txt' './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
./cloudsend.sh -g -p 'MySecretPass' '{file1,file2,file3}' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
cat file | ./cloudsend.sh - 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28' -r destFileName Apa itu "https://cloud.mydomain.net/s/fLDzToZF4MLvG28"?
Apa itu "tautan folder"?
Dari mana saya mendapatkannya?
Khususnya bagian "s/fLDzToZF4MLvG28"?
Anda harus membagikan Folder yang dapat ditulisi dan menggunakan tautan yang dihasilkan
Dari Dokumentasi Nextcloud 21