migrate file upload to rsync
This commit is contained in:
parent
48c38c8159
commit
cca0c68b27
4 changed files with 21 additions and 14 deletions
25
.aliases.sh
25
.aliases.sh
|
@ -78,26 +78,31 @@ function upload() {
|
|||
if [ "$#" -ne 2 ]; then
|
||||
echo "Invalid number of parameters"
|
||||
echo "usage: upload <target_dir> <file>"
|
||||
echo "example: upload tmp img.png"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -z "$FILE_STORAGE_API_KEY" ]; then
|
||||
echo "No API key set, did you forget to 'source ~/.tokens'?"
|
||||
if [ -z "$RSYNC_HOST" ]; then
|
||||
echo "No rsync env variables set, did you forget to source?"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Uploading to $1/$2"
|
||||
|
||||
curl --request PUT \
|
||||
--url "$FILE_STORAGE_API_URL/$1/$2" \
|
||||
--header "AccessKey: $FILE_STORAGE_API_KEY" \
|
||||
--header "Content-Type: application/octet-stream" \
|
||||
--header "accept: application/json" \
|
||||
--data-binary "@$2"
|
||||
rsync \
|
||||
--verbose \
|
||||
--recursive \
|
||||
--rsh "ssh -p $RSYNC_PORT -i $HOME/.ssh/$RSYNC_KEY" \
|
||||
"$2" \
|
||||
"$RSYNC_USER@$RSYNC_HOST:$RSYNC_DEST/$1"
|
||||
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "$FILE_STORAGE_EXTERNAL_URL/$1/$2 (copied to clipboard)"
|
||||
echo "$FILE_STORAGE_EXTERNAL_URL/$1/$2" | xclip -sel clip
|
||||
echo "https://$RSYNC_HOST/$1/$2 (copied to clipboard)"
|
||||
echo "https://$RSYNC_HOST/$1/$2" | xclip -sel clip
|
||||
}
|
||||
|
||||
function upload_all() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue