client/upload: Offer copying link to keyboard

This commit is contained in:
Albert S. 2021-03-21 22:13:42 +01:00
parent dd9417ab9e
commit 823d97002f

View File

@ -28,10 +28,10 @@ fi
ssh $UPLOADER_SSH_SERVER mkdir $UPLOADER_UPLOAD_DIR/$random
BASENAME=$( basename "$1" )
LINK=""
if [ $PLAIN -eq 1 ] ; then
scp -r "$1" $UPLOADER_SSH_SERVER:$UPLOADER_UPLOAD_DIR/$random/$BASENAME
echo "$UPLOADER_URL_PREFIX/$random/$BASENAME"
LINK="$UPLOADER_URL_PREFIX/$random/$BASENAME"
else
KEYBASE=$(openssl rand -base64 32)
KEYASHEX=$(echo -n $KEYBASE | base64 -d | xxd -p -c 10000) # linebreak after 10000 chars. i.e. never
@ -50,9 +50,16 @@ else
fi
$PIPER | openssl enc -aes-256-cbc -K "$KEYASHEX" -iv $(printf '0%.0s' {1..32}) | # print '0' 32 times = 16 bytes as hex
ssh $UPLOADER_SSH_SERVER "cat > $UPLOADER_UPLOAD_DIR/$random/$FSNAME"
echo "$UPLOADER_URL_PREFIX#$random/$FSNAME:$KEYBASE:$MIMETYPE:$UPLOADED_NAME"
ssh $UPLOADER_SSH_SERVER "cat > $UPLOADER_UPLOAD_DIR/$random/$FSNAME"
LINK="$UPLOADER_URL_PREFIX#$random/$FSNAME:$KEYBASE:$MIMETYPE:$UPLOADED_NAME"
fi
echo "$LINK"
echo ""
echo "Press any key to copy the link to your clipboard" 1>&2
read -n 1 -t 5 ANSWER
if [ -n "$ANSWER" ] ; then
echo "$LINK" | xclip -selection clipboard
fi
ssh $UPLOADER_SSH_SERVER chown -R $UPLOADER_FILE_OWNER $UPLOADER_UPLOAD_DIR/$random/
ssh $UPLOADER_SSH_SERVER "echo $when:$random >> $UPLOADER_EXPIRATION_FILE"