Linux命令上傳文件到百度網盤

系統環境:
CentOS7 + Python 2.7
安裝軟件工具:
pip install requests
pip install bypy
授權登陸:
執行 bypy info,顯示下邊信息,根據提示,通過瀏覽器訪問下邊灰色的https鏈接,如果此時百度網盤賬號正在登陸,會出現長串授權碼,複製。

[root@localhost ~]# bypy info
Please visit:   # 訪問下邊這個連接,複製授權碼
https://openapi.baidu.com/oauth/2.0/authorize?scope=basic+netdisk&redirect_uri=oob&response_type=code&client_id=q8WE4EpCsau1oS0MplgMKNBn845c39907e704f38dfebd29be380b80f
And authorize this app
Paste the Authorization Code here within 10 minutes.
Press [Enter] when you are done    # 提示在下邊粘貼授權碼

用瀏覽器打開上面的鏈接
在這裏插入圖片描述
輸入授權碼

Press [Enter] when you are done
845c39907e704f38dfebd29be380b80f
Authorizing, please be patient, it may take upto None seconds...
Authorizing/refreshing with the OpenShift server ...
OpenShift server failed, authorizing/refreshing with the Heroku server ...
Successfully authorized
Quota: 2.020TB
Used: 1.215TB

授權成功

測試上傳和同步本地文件到雲盤
由於百度PCS API權限限制,程序只能存取百度雲端/apps/bypy目錄下面的文件和目錄。我們可以通過:

[root@localhost ~]# bypy list
/apps/bypy ($t $f $s $m $d):

bypy常用命令

bypy list 查看目錄

bypy mkdir 新建目錄

bypy upload 把本地當前目錄下的文件同步到百度雲盤

bypy downdir 把雲盤上的內容同步到本地

bypy list 顯示文檔
bypy upload filename 上傳文檔

bypy downdir filename 下載文件(存在問題)

bypy compare 比較本地當前目錄和雲盤(程序的)根目錄

bypy -c 取消令牌文件。一段時間後要重新授權

命令:bypy upload localfile cloudfile

說明:1) localfile爲本地文件路徑

2)cloudfile爲雲端文件路徑

3)由於百度的限制,最終文件只能上傳到雲盤,我的應用程序(apps) /bypy下

例: bypy upload /root/Outline-Manager.exe
上傳完成後可以在
顯示上傳進度,可使用命令:bypy -v upload localfile cloudfile
例:bypy -v upload /root/Outline-Manager.exe

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章