]> Sergey Matveev's repositories - nnn.git/commitdiff
Use file.io to ipload files
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 24 Dec 2019 05:41:39 +0000 (11:11 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 24 Dec 2019 05:41:39 +0000 (11:11 +0530)
plugins/README.md
plugins/transfer [deleted file]
plugins/upload [new file with mode: 0755]

index 3e85ec93c02722d9d7ab0d7d5d6defbaf98d0b1a..bbb97497ea25883378316dbc1e3752698b954bb9 100644 (file)
@@ -52,10 +52,10 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina
 | ringtone | Create a variable bitrate mp3 ringtone from file | sh | date, ffmpeg |
 | splitjoin | Split file or join selection | sh | split, cat |
 | suedit | Edit file using superuser permissions | sh | sudoedit/sudo/doas |
-| transfer | Upload file to transfer.sh | sh | curl |
 | treeview | Informative tree output in `$EDITOR` | sh | tree |
 | uidgid | List user and group of all files in dir | sh | ls, less |
 | upgrade | Upgrade nnn manually on Debian 9 Stretch | sh | curl |
+| upload | Upload file to file.io | sh | curl, jq, tr |
 | vidthumb | Show video thumbnails in terminal | sh | [ffmpegthumbnailer](https://github.com/dirkvdb/ffmpegthumbnailer),<br>[lsix](https://github.com/hackerb9/lsix) |
 | wall | Set wallpaper or change colorscheme | sh | nitrogen/pywal |
 
diff --git a/plugins/transfer b/plugins/transfer
deleted file mode 100755 (executable)
index 05992a3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env sh
-
-# Description: Upload a file to transfer.sh
-#
-# Shell: POSIX compliant
-# Author: Arun Prakash Jana
-
-if ! [ -z "$1" ]; then
-    # Upload the file, show the download link and wait till user presses any key
-    curl -s --upload-file "$1" https://transfer.sh/"$(basename "$1")"
-    echo
-    read -r _
-
-    # To write download link to "$1".loc and exit
-    # curl -s --upload-file "$1" https://transfer.sh/`basename "$1"` -o `basename "$1"`.loc
-fi
diff --git a/plugins/upload b/plugins/upload
new file mode 100755 (executable)
index 0000000..f74ee5c
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env sh
+
+# Description: Upload a file to file.io
+# Requires: curl, jq, tr
+# Note: File set to expire after a week
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+if [ -s "$1" ]; then
+    # 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
+else
+    echo "empty file!"
+fi
+    read -r _