1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 更新 【2021.04.02】 目前同时支持国际版、个人版(家庭版)。 【2021.04.01】 修复授权失败、上传文件大小为0等问题。 现已支持arm、x86、x64平台的系统。 【2021.03.27】 新增多线程上传、MacOS客户端。 修复了一个致命bug,建议之前装过的更新下程序。 功能 支持上传文件和文件夹到指定目录,并保持上传前的目录结构。 支持命令参数使用,方便外部程序调用。 支持自定义上传分块大小。 支持多线程上传(多文件同时上传)。 支持根据文件大小动态调整重试次数,对抗不好的网络环境。 可以使用Telegram Bot实时监控上传进度 Github地址:https://github.com/gaowanliang/OneDriveUploader
萌咖大佬写了一个 非常好的版本 ,可惜并没有开源,而且已经好久都没有更新了。这个项目作为从 DownloadBot 中独立出来的一个简易上传工具,使得上传到OneDrive更加方便。
这里只详细说下Linux的用法,Windows后面大概说下。
Windows、MacOS系统下载地址→传送门 ,直接将程序下载到本地后,按照下面方法进行授权、初始化,然后就可以使用命令上传了。
授权认证 点击右侧URL登录并授权,授权地址→【国际版、个人版(家庭版)】
授权后会获取一个localhost开头打不开的链接,这里复制好整个链接地址,包括localhost。
安装OneDriveUploader 打开这个界面,选择适合你系统的版本:https://github.com/gaowanliang/OneDriveUploader/releases
这里以Linux 64位为例,当前最新版本为v1.4-fix,应该下载 OneDriveUploader_Linux_x86_64.tar.gz 这个文件
1 2 3 4 5 6 7 8 9 10 wget https://github.com/gaowanliang/OneDriveUploader/releases/download/v1.4-fix/OneDriveUploader_Linux_x86_64.tar.gz tar -zxvf OneDriveUploader_Linux_x86_64.tar.gz -C /usr/local /bin/ chmod +x /usr/local /bin/OneDriveUploader ln -s /usr/local /bin/OneDriveUploader /usr/bin/OneDriveUploader
初始化配置 1 2 3 4 5 6 OneDriveUploader -a "url" -l zh-CN OneDriveUploader -a "url" -v 1 -l zh-CN
如果提示注册成功
类似信息,则初始化成功。
使用命令 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 Usage of OneDriveUploader: -a string Setup and Init auth.json. -b string -c string -r string -l string -f string -t string -to int -tgbot string -uid string -m int -v int
命令示例 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 29 OneDriveUploader -c xxx.json -f "mm00.jpg" OneDriveUploader -c xxx.json -f "Download" OneDriveUploader -c xxx.json -f "Download" -r "Test" OneDriveUploader -c xxx.json -t 10 -f "Download" OneDriveUploader -c xxx.json -t 10 -f "Download" -m 1 OneDriveUploader -c xxx.json -t 10 -f "Download" -to 30 OneDriveUploader -c xxx.json -t 10 -f "Download" -tgbot "123456:xxxxxxxx" -uid 123456789 OneDriveUploader -c xxx.json -t 10 -f "Download" -tgbot "1" OneDriveUploader -c xxx.json -t 15 -b 20 -f "Download"
/urs/local/auth.json
为初始化时,生成的*.json绝对路径地址,本文默认/root/auth.json
,自行调整。
Aria2自动上传 同样的这里也会提供个配套的Aria2自动上传脚本 上传脚本代码如下:
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 29 30 31 32 33 34 35 36 37 38 #!/bin/bash GID="$1 " ; FileNum="$2 " ; File="$3 " ; MaxSize="157286400" ; Thread="3" ; Block="20" ; RemoteDIR="" ; LocalDIR="/www/download/" ; Uploader="/usr/local/bin/OneDriveUploader" ; Config="/root/auth.json" ; if [[ -z $(echo "$FileNum " |grep -o '[0-9]*' |head -n1) ]]; then FileNum='0' ; fi if [[ "$FileNum " -le '0' ]]; then exit 0; fi if [[ "$# " != '3' ]]; then exit 0; fi function LoadFile (){ if [[ ! -e "${Uploader} " ]]; then return ; fi IFS_BAK=$IFS IFS=$'\n' tmpFile="$(echo "${File/#$LocalDIR} " |cut -f1 -d'/') " FileLoad="${LocalDIR} ${tmpFile} " if [[ ! -e "${FileLoad} " ]]; then return ; fi ItemSize=$(du -s "${FileLoad} " |cut -f1 |grep -o '[0-9]*' |head -n1) if [[ -z "$ItemSize " ]]; then return ; fi if [[ "$ItemSize " -ge "$MaxSize " ]]; then echo -ne "\033[33m${FileLoad} \033[0mtoo large to spik.\n" ; return ; fi ${Uploader} -c "${Config} " -t "${Thread} " -b "${Block} " -f "${FileLoad} " -r "${RemoteDIR} " if [[ $? == '0' ]]; then rm -rf "${FileLoad} " ; fi IFS=$IFS_BAK } LoadFile;
编辑好上传脚本后,可以检测下脚本编码是否正确,比如我脚本路径为/root/upload.sh
,使用命令:
如果无任何输出,则正确,反之输出类似$’r’: command not found错误,则需要转换下编码格式,具体步骤如下。
先安装dos2unix:
1 2 3 4 5 6 7 8 9 yum install dos2unix -y apt install dos2unix -y 再转换编码: dos2unix /root/upload.sh
Windows使用 这里就随便补充下Windows使用,先下载程序文件,下载地址→传送门 。
比如我将exe文件放到D盘,然后使用Win+R,输入CMD运行,调出窗口后,使用命令:
1 2 3 4 5 6 7 8 9 #进入D盘 cd /d D:\#国际版初始化,将url换成你上面复制的授权地址,包括http://loaclhost。 OneDriveUploader.exe -a "url" -l zh-CN #个人版(家庭版)初始化,将url换成你上面复制的授权地址,包括http://loaclhost。 OneDriveUploader.exe -a "url" -v 1 -l zh-CN
然后上传命令和上面一样,只需要把OneDriveUploader
改成OneDriveUploader.exe
即可。