22 lines
697 B
Plaintext
22 lines
697 B
Plaintext
var domain = https://transfer.hostux.net/
|
||
edit:add-var transfer~ {|@argv|
|
||
use path
|
||
if (not-eq (count $argv) 0) {
|
||
fail('Usage: transfer <fichier_ou_repertoire>')
|
||
}
|
||
var file = $argv[0]
|
||
var filename = (basename $file)
|
||
var is_dir = (path:is-dir &follow-symlink=$true $file)
|
||
var is_regular = (path:is-regular &follow-symlink=$true $file)
|
||
if (not (and is_dir is_regular)) {
|
||
fail("'"$file"' n’existe pas")
|
||
}
|
||
if is_dir {
|
||
set filename = $filename'.tar.gz'
|
||
cd $file
|
||
tar -c . | e:curl --progress-bar --upload-file - $domain$filename | tee /dev/null
|
||
} else {
|
||
cat $file | e:curl --progress-bar --upload-file - $domain$filename | teee /dev/null
|
||
}
|
||
}
|