cli client: update and move to contrib

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
Gunwant Jain
2022-01-18 10:19:28 +05:30
parent e17a5f7cdb
commit e91393f63c
3 changed files with 16 additions and 11 deletions

View File

@@ -25,7 +25,7 @@ RUN cargo clean
###### Runner Image
FROM scratch as runner
COPY --from=builder /app/empty_upload upload
COPY ./client upload/client
COPY ./contrib/cli/client upload/client
COPY ./templates templates
COPY ./static static
COPY ./themes themes

10
client
View File

@@ -1,10 +0,0 @@
#!/bin/sh
url="http://127.0.0.1:8000"
filepath="$1"
filename=$(basename -- "$filepath")
extension="${filename##*.}"
response=$(curl --data-binary @${filepath:-/dev/stdin} --url $url)
echo "$url$response"".""$extension" | tee >(xclip -selection clipboard)

15
contrib/cli/client Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Change the url accordingly
URL="https://bin.wantguns.dev"
FILEPATH="$1"
FILENAME=$(basename -- "$FILEPATH")
EXTENSION="${FILENAME##*.}"
RESPONSE=$(curl --data-binary @${FILEPATH:-/dev/stdin} --url $URL)
PASTELINK="$URL$RESPONSE"
[ -z "$EXTENSION" ] && \
echo "$PASTELINK" || \
echo "$PASTELINK.$EXTENSION"