當前位置:
首頁 > 知識 > 自動共享和上傳文件到兼容的託管站點

自動共享和上傳文件到兼容的託管站點

自動共享和上傳文件到兼容的託管站點


Anypaste 將會根據你想上傳的文件的類型來自動挑選合適的託管站點。簡單地說,照片將被上傳到圖像託管站點,視頻被傳到視頻站點,代碼被傳到 pastebin。-- Sk(作者)

前陣子我們寫了一個關於 Transfer.sh 的指南,它允許你使用命令行通過互聯網來分享文件。今天,我們來看看另一種文件分享實用工具 Anypaste。這是一個基於文件類型自動共享和上傳文件到兼容託管站點的簡單腳本。你不需要去手動登錄到託管站點來上傳或分享你的文件。Anypaste 將會根據你想上傳的文件的類型來自動挑選合適的託管站點。簡單地說,照片將被上傳到圖像託管站點,視頻被傳到視頻站點,代碼被傳到 pastebin。難道不是很酷的嗎?Anypaste 是一個完全開源、免費、輕量的腳本,你可以通過命令行完成所有操作。因此,你不需要依靠那些臃腫的、需要消耗大量內存的 GUI 應用來上傳和共享文件。

安裝

正如我所說,這僅僅是一個腳本。所以不存在任何複雜的安裝步驟。只需要將腳本下載後放置在你想要運行的位置(例如 /usr/bin/),並將其設置為可執行文件後就可以直接使用了。此外,你也可以通過下面的這兩條命令來快速安裝 Anypaste。

sudo curl -o /usr/bin/anypaste https://anypaste.xyz/sh
sudo chmod +x /usr/bin/anypaste

就是這樣簡單。如果需要更新老的 Anypaste 版本,只需要用新的可執行文件覆寫舊的即可。

現在,讓我們看看一些實例。


配置

Anypaste 開箱即用,並不需要特別的配置。默認的配置文件是 ~/.config/anypaste.conf,這個文件在你第一次運行 Anypaste 時會自動創建。

需要配置的選項只有 ap_plugins。Anypaste 使用插件系統上傳文件。每個站點(的上傳)都由一個特定的插件表示。你可以在 anypaste.conf 文件中的 ap-plugins directive 位置瀏覽可用的插件列表。

# List of plugins
# If there are multiple compatible plugins, precedence is determined
# by which one is listed first in this array
ap_plugins=(
# Videos/Gifs
"sendvid" "streamable" "gfycat"
# Images
"tinyimg" "vgyme"
# Audio
"instaudio"
# Text
"hastebin" "ixio" "sprunge"
# Documents
"docdroid"
# Any file
"jirafeau" "fileio"
)
[...]

如果你要安裝一個新的插件,將它添加進這個列表中就可以了。如果你想禁用一個默認插件,只需要將它從列表中移除即可。如果有多個兼容的插件,排列中的第一個會被選擇,因此順序很重要


用法

上傳一個簡單的文件,例如 test.png,可以運行以下命令:

anypaste test.png

輸出示例:

Current file: test.png
Attempting to upload with plugin "tinyimg"
######################################################################## 100.0%

Direct Link: https://tinyimg.io/i/Sa1zsjj.png

Upload complete.
All files processed. Have a nice day!

正如輸出結果中所看到的,Anypaste 通過自動匹配圖像文件 test.png 發現了兼容的託管站點( https://tinyimg.io),並將文件上傳到了該站點。此外,Anypaste 也為我們提供了用於直接瀏覽/下載該文件的鏈接。

不僅是 png 格式文件,你還可以上傳任何其他圖片格式的文件。例如,下面的命令將會上傳 gif 格式文件:

$ anypaste file.gif
Current file: file.gif
Plugin "streamable" is compatible, but missing config parameters: "streamable_email" "streamable_password"
You can set them in /home/sk/.config/anypaste.conf
Attempting to upload with plugin "gfycat"
######################################################################## 100.0%
Reminder: Gfycat needs time to encode. Your video will not appear right away.

Link: https://gfycat.com/MisguidedQuaintBergerpicard
Direct(ish) Link: https://thumbs.gfycat.com/MisguidedQuaintBergerpicard-size_restricted.gif

Upload complete.
All files processed. Have a nice day!

你可以將鏈接分享給你的家庭、朋友和同事們。下圖是我剛剛將圖片上傳到 gfycat 網站的截圖。

自動共享和上傳文件到兼容的託管站點

也可以一次同時上傳多個(相同格式或不同格式)文件。

下面的例子提供參考,這裡我會上傳兩個不同的文件,包含一個圖片文件和一個視頻文件:

anypaste image.png video.mp4

輸出示例:

Current file: image.png
Attempting to upload with plugin "tinyimg"
######################################################################## 100.0%

Direct Link: https://tinyimg.io/i/au1PHpg.png

Upload complete.
Current file: video.mp4
Plugin "streamable" is compatible, but missing config parameters: "streamable_email" "streamable_password"
You can set them in /home/sk/.config/anypaste.conf
Attempting to upload with plugin "sendvid"
######################################################################## 100.0%

Link: http://sendvid.com/wwy7w96h
Delete/Edit: http://sendvid.com/wwy7w96h?secret=39c0af2d-d8bf-4d3d-bad3-ad37432a40a5

Upload complete.
All files processed. Have a nice day!

Anypaste 針對兩個文件自動發現了與之相兼容的託管站點並成功上傳。

正如你在上述用法介紹部分的例子中注意到的,Anypaste 會自動挑選最佳的插件。此外,你可以指定插件進行文件上傳,這裡提供一個上傳到 gfycat 的案例,運行以下命令:

anypaste -p gfycat file.gif

輸出示例:

Current file: file.gif
Plugin "streamable" is compatible, but missing config parameters: "streamable_email" "streamable_password"
You can set them in /home/sk/.config/anypaste.conf
Attempting to upload with plugin "gfycat"
######################################################################## 100.0%
Reminder: Gfycat needs time to encode. Your video will not appear right away.

Link: https://gfycat.com/GrayDifferentCollie
Direct(ish) Link: https://thumbs.gfycat.com/GrayDifferentCollie-size_restricted.gif

Upload complete.
All files processed. Have a nice day!

如果要使用特定插件進行文件上傳,可以通過以下命令繞過兼容性檢查:

anypaste -fp gfycat file.gif

如果你發現在配置文件中忽略了特定的插件,你仍然可以強制 Anypaste 去使用特定的插件,只不過需要加上 -xp 參數。

anypaste -xp gfycat file.gif

如果想要以交互模式上傳文件,可以在命令後加上 -i 標籤:

$ anypaste -i file.gif
Current file: file.gif
Determine compatible plugins automatically? [Y/n] **n**
The following plugins were found: "sendvid" "streamable" "gfycat" "tinyimg" "vgyme" "instaudio" "hastebin" "ixio" "sprunge" "docdroid" "jirafeau" "fileio"

Enter the (partial) name of a plugin, or nothing for automatic selection
**gfycat**
Attempt to upload with plugin "gfycat"? [Y/n] **y**
Attempting to upload with plugin "gfycat"
######################################################################## 100.0%
Reminder: Gfycat needs time to encode. Your video will not appear right away.

Link: https://gfycat.com/WaryAshamedBlackbear
Direct(ish) Link: https://thumbs.gfycat.com/WaryAshamedBlackbear-size_restricted.gif

Upload complete.
All files processed. Have a nice day!

正如你所見,Anypaste 首先詢問了我是否需要自動確定插件。因為我不想自動尋找插件,所以我回復了 「No」。之後,Anypaste 列出了所有可選擇的插件,並要求我從列表中選擇一個。同樣的,你可以上傳和共享不同類型的文件,相關文件會被上傳到相兼容的站點。

無論你何時上傳一個視頻文件,Anypaste 都會將其上傳到以下站點中的一個:

  1. sendvid
  2. streamable
  3. gfycat

這裡注意列表順序,Anypaste 將首先將文件上傳到 sendvid 站點,如果沒有 sendvid 的插件可供使用,Anypaste 將會嘗試順序中的另外兩個站點。當然你也可以通過更改配置文件來修改順序。

圖像文件上傳站點:

  1. tinyimg.io
  2. vgy.me

音頻文件上傳站點:

  1. instaud

文本文件上傳站點:

  1. hastebin
  2. ix.io
  3. sprunge.us

文檔上傳站點:

  1. docdroid

其他任意類型的文件上傳站點:

  1. jirafeau
  2. file.io

上面列出來的部分站點一段特定的時間後會刪除上傳的內容,所以在上傳和分享內容時應先明確這些站點的條款和條件。


結論

在我看來,識別文件並決定將其上傳到何處的想法非常棒,而且開發者也以恰當的方式完美地實現了它。毫無疑問,Anypaste 對那些在互聯網上需要頻繁分享文件的人們非常有用,我希望你也能這麼覺得。

這就是今天的全部內容,後面會有越來越多的好東西分享給大家。再見啦!



via: https://www.ostechnix.com/anypaste-share-upload-files-compatible-hosting-sites-automatically/

作者: SK 譯者: lixin555 校對: wxy

本文由 LCTT 原創編譯, Linux中國 榮譽推出


點擊「了解更多」可訪問文內鏈接

喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!


請您繼續閱讀更多來自 Linux技術 的精彩文章:

大多數惡意廣告可追溯到三個廣告網路
從 Firefox 72 開始:標準模式將默認啟用指紋識別追蹤保護選項