OneDrive For Business是目前国内可访问、不限速、容量最大的网盘。为了方便使用和建立自己的中转站,这里收集了相关CLI工具。
工具名 | 编程语言 | 文件上传 | 文件夹上传 | 同步 | API | 显示上传进度 |
---|---|---|---|---|---|---|
odrive | Bash&Python | × | ✓ | ✓ | 不能自定义 | × |
bash-onedrive-upload | Bash | ✓ | ✓ | × | 专属型api、 通用型GraphAPI | ✓ |
onedrivecmd | Python | ✓ | × | × | 专属型api | ✓ |
GoodSync | Bash | × | × | ✓ | 不能自定义 | ? |
skilion/onedrive | ? | × | × | ✓ | 通用型GraphAPI | × |
rclone | Go | ✓ | ✓ | ✓ | 专属型api | ? |
onedriveClient | Python3 | ? | ? | ? | ? | ? |
0oVicero0/OneDrive | Bash | ✓ | ✓ | × | 专属型api | ✓ |
#odrive使用
进入odrive登录页面,使用office365账号登录,授权。
进入https://www.odrive.com/account/authcodes,获取Auth Keys。
修改onedrive for business的name,如:OD4B,作为后期远程上传路径。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#安装与运行 wget https://s3.amazonaws.com/cdn-agent.odrive.com/preview5/odriveagent-client-linux-64bit-920.tar.gz wget https://s3.amazonaws.com/cdn-agent.odrive.com/preview5/odriveSyncAgent-prod-lnx-920_64bit.tar.gz tar -xvzf odriveagent-client-linux-64bit-920.tar.gz tar -xvzf odriveSyncAgent-prod-lnx-920_64bit.tar.gz nohup ./odriveagent > /dev/null 2>&1 & #验证Auth Keys ./odrive authenticate 090ec82b-****-****-****-f7355a21671e-593cb7d5 #文件夹上传(./odrive backup 本地路径 远程路径) ./odrive backup ~/blog /OD4B #挂载同步(./odrive mount 本地路径 远程路径) ./odrive mount ~/blog /OD4B/blog #取消挂载 ./odrive unmount ~/blog |
odrive也可以取外链分享,大流量下是否会失效,还需测试。测试链接:https://www.odrive.com/s/5fab93e4-cfdd-4dbc-a174-6aec30576f5d-5943e034
#bash-onedrive-upload使用(通用型API)
所需组件:
curl is used for accessing the API.
grep is used for filtering the parsed json output.
cut is used for value extraction from the filtered json output.
xargs is used for multi-threaded file uploads.
dd is used for chunked file uploads.
stat is used to determine the filesize.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#安装 git clone --recursive -b feature/28-converged-applications https://github.com/fkalis/bash-onedrive-upload.git cd ./bash-onedrive-upload #写入API vi onedrive.cfg # Authentication config export api_client_id="30700441-aaa4-4d29-a708-5bbd6f908b15" export api_client_secret="k92FKd56GbYncPiMkfOVMVj" export api_reply_url="http://localhost" #新建标签页,访问下面网站,登录office365,授权 https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=30700441-aaa4-4d29-a708-5bbd6f908b15&response_type=code&redirect_uri=http://localhost&response_mode=query&scope=offline_access https://graph.microsoft.com/files.readwrite #返回如下地址,星号部分为所需部分("code="至"&session_state"之间) http://localhost/?code=**************&session_state=..... #验证,回车后输入上面星号表示的返回值 ./onedrive-authorize #上传文件 ./onedrive-upload file1 file2 ./onedrive-upload file*.png #上传文件夹 ./onedrive-upload /path/to/folder |
#onedrivecmd使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#更新python版本 wget http://7xpt4s.com1.z0.glb.clouddn.com/update-python2.7.12.sh && sudo bash update-python2.7.12.sh #安装 git clone https://github.com/cnbeining/onedrivecmd.git cd ./onedrivecmd sudo pip install -r requirments.txt sudo pip install --upgrade -r requirments.txt #修改API cd ./utils vi static.py client_id_business = 'f46e7a0f-c813-4f6e-814e-9d2d611a193b' client_secret_business = 'zQl2wger66YWyLpYOTmstBamtyui5ZBXYXoivaNVhxQ=' #访问下面网站,获取返回值 https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=f46e7a0f-c813-4f6e-814e-9d2d611a193b&redirect_uri=https://onedrive.live.com/about/business/ #使用上面的返回值验证 python onedrivecmd.py init business #上传文件(python onedrivecmd.py put 本地文件路径 od:/path) python onedrivecmd.py put ./update-python2.7.12.sh od:/ |
#0oVicero0/OneDrive使用
所需组件:
curl is used for accessing the API.
grep is used for filtering the parsed json output.
cut is used for value extraction from the filtered json output.
xargs is used for multi-threaded file uploads.
dd is used for chunked file uploads.
stat is used to determine the filesize.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#项目主页给出了一键安装脚本,对于没有root权限的可以照下面的步骤来使用: #安装 git clone https://github.com/0oVicero0/OneDrive.git cd ./OneDrive/Business chmod +x onedrive chmod +x onedrive-d chmod +x json-parser #配置 vi onedrive.cfg export api_client_id="f46e7a0f-c813-4f6e-814e-9d2d611a193b " export api_client_secret="zQl2wger66YWyLpYOTmstBamtyui5ZBXYXoivaNVhxQ= " #登录授权,获取返回值 https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=f46e7a0f-c813-4f6e-814e-9d2d611a193b&redirect_uri=https://onedrive.live.com/about/business/ #用返回值认证 ./onedrive -a #文件夹上传(onedrive-d要使用绝对路径) ~/OneDrive/Business/onedrive-d ./bash-test #文件上传 ./onedrive file1 file2 ./onedrive file*.png |
#注意
onedrive上传时,对文件名有些限制,尽量不要有中文!尽量不要有中文!尽量不要有中文!详情请见Restrictions and limitations when you sync files and folders
One Reply to “OneDrive For Business CLI”