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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值