10000 add support for multiple files using ffsend by darukutsu · Pull Request #1523 · jarun/nnn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add support for multiple files using ffsend #1523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions plugins/upload
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,38 @@
# Dependencies: ffsend (https://github.com/timvisee/ffsend), curl, jq, tr
#
# Note: Binary file set to expire after a week
# Uploading selection is handled using ffsend.
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana

if [ -n "$1" ] && [ -s "$1" ]; then
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
if [ -s "$selection" ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the documentation that selection is handled exclusively using ffsend.

if type ffsend >/dev/null 2>&1; then
ffsend -fiq u "$1"
elif [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "text" ]; then
curl -F "f:1=@$1" ix.io
# File name will be randomized foo.tar
xargs -0 < "$selection" ffsend u
else
# Upload the file, show the download link and wait till user presses any key
curl -s -F "file=@$1" https://file.io/?expires=1w | jq '.link' | tr -d '"'

# To write download link to "$1".loc and exit
# curl -s -F "file=@$1" https://file.io/?expires=1w -o `basename "$1"`.loc
printf "ffsend is required to upload selection."
fi

# Clear selection
printf "-" > "$NNN_PIPE"
else
printf "empty file!"
if [ -n "$1" ] && [ -s "$1" ]; then
if type ffsend >/dev/null 2>&1; then
ffsend -fiq u "$1"
elif [ "$(mimetype --output-format %m "$1" | awk -F '/' '{print $1}')" = "text" ]; then
curl -F "f:1=@$1" ix.io
else
# Upload the file, show the download link and wait till user presses any key
curl -s -F "file=@$1" https://file.io/?expires=1w | jq '.link' | tr -d '"'

# To write download link to "$1".loc and exit
# curl -s -F "file=@$1" https://file.io/?expires=1w -o `basename "$1"`.loc
fi
else
printf "empty file!"
fi
fi

read -r _
0