惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

Rat's Blog - OneDrive

一个好用的OneDrive网盘上传工具,支持文件和文件夹上传 - Rat's Blog 微软OneDrive网盘免费升级到25T容量教程 - Rat's Blog CuteOne:一款基于Python3的OneDrive多网盘挂载程序,带会员/同步等功能 - Rat's Blog 一个可以解决因api抽风出现空目录的OneDrive目录程序:OneList - Rat's Blog Microsoft Office365 E3 MSDN全局管理员修改自身和用户OneDrive存储大小方法 - Rat's Blog 分享一些1T OneDrive账号,及免费获取一年Office 365企业版E3 - Rat's Blog PyOne一键安装脚本 for CentOS 7/Debian 8+/Ubuntu 16+ PyOne:一款支持绑定多网盘的OneDrive文件本地化浏览系统 - Rat's Blog Windows下使用RaiDrive挂载Google Drive/OneDrive网盘为本地硬盘使用 - Rat's Blog
VPS上传文件到OneDrive网盘脚本,可配合Aria2实现自动上传 - Rat's Blog
博主: Rat's · 2018-11-19 · via Rat's Blog - OneDrive

说明:我们从VPS上传文件到OneDrive网盘的方法很多,包括Rclone挂载,OneIndex程序的上传功能,不过2个在上传的时候都还是有点BUG,前者会出现丢文件的情况,后者也会出现上传失败,都不是很理想,这里博主再介绍个OneDrive上传脚本,几乎不会出现上传问题,很好用,由萌咖大佬制作,并将其适用于Aria2的自动上传,这里说下具体操作。

提示

【2019.11.28】
该版本不再维护和更新,请移植Go版的上传工具,更高效和快速,地址:https://www.moerats.com/archives/1006/

更新

【2018.12.16】
应一些同学需求,新增上传到指定文件夹的方法。
【2018.11.19】
OneDrive上传脚本BUG已被萌咖大佬修复,修复了空格处理不当,导致部分带空格的文件夹上传失败,从而影响Aria2上传脚本。
【2018.10.30】
修复Aria2上传脚本BUG,包括修复了不能上传文件夹功能,修复了不能正确上传文件名中包含空格的项目。
【2018.10.29】
优化OneDrive网盘脚本。优化认证步骤。
独家分享萌咖大佬的Aria2自动上传脚本,判断更加细节,支持单文件、文件夹里的单文件、文件夹里的多文件及文件夹上传。超过15G文件停止上传(onedrive限制)。

说明

【2018.11.19】
#目前脚本修复的差不多了,博主测试各种带空格的文件夹自动上传都没问题。

#如果依然出现有些文件上传不了?
出现这种情况的话,大概是文件虽然下载完成了,但一直卡在做种阶段,导致参数传不到自动上传脚本,从而文件夹也上传不了。
解决方法:在配置文件里加入seed-time=0参数(意思是停止做种),再重启Aria2即可。

方法

Github地址:https://github.com/0oVicero0/OneDrive

脚本特性:脚本支持文件夹上传,支持获取文件的匿名直链,且只适用于OneDrive非个人版。

1、安装脚本
安装curl,用于访问API

#Ubuntu和Debian系统
apt-get install -y curl

#Centos系统
yum install curl -y

运行命令安装脚本:

#为了方便小白,本脚本内置萌咖大佬永久有效的应用参数,可以直接使用,如果你不放心可以自己获取参数,不过可能会遇到很多坑,建议直接使用脚本默认的参数
wget --no-check-certificate -qO- "https://raw.githubusercontent.com/0oVicero0/OneDrive/master/OneDrive.sh" |bash

本脚本需要三个参数Client IDSecretReply URL,均需要在/usr/local/etc/OneDrive/onedrive.cfg文件里修改,参数获取看下面,当然你也可以不用管,直接进行步骤3

2、获取参数
先访问Microsoft Azure Management Portal,然后点击左侧菜单栏中的Azure Active Directorg,选择应用注册,再点击页面上方的新应用程序注册。
请输入图片描述
输入名称如:OneDrive for Linux,应用程序类型选择Web应用/API,填入登陆URLhttps://login.microsoftonline.com/,再点击创建。
请输入图片描述
然后点击刚刚创建的应用程序,复制应用程序ID,即脚本需要的Client ID参数,再点击左上角的设置。
请输入图片描述
然后进行如下修改:
请输入图片描述

#点击右边的回复URL,将其修改为:https://onedrive.live.com/about/business/,即脚本所需要的Reply URL参数。
#点击所需权限,点击Windows Azure Active Directory确认是否已选中Sign in and user profile,如果没有则选中并点击完成。
#点击上方的添加,点击选择API,选中Office 365 SharePoint Online,并点击选择。在选择权限中选中Read user files 和Read and write user files,并点击选择。点击完成按钮,并关掉此小窗口。
#点击密钥,填入密钥描述,如:OneDrive,选择年限1年,点击保存,再复制密匙,即脚本所需要的Secret参数。

不过这里说下密匙(Secret参数)填写的一个坑,由唯一度博主填平。就是当我们获取到带+号的密匙时候,我们需要使用编码符号,把+改成%2B,然后再填入脚本里,不然最后会出现Something went wrong, here is the API response的错误,导致验证失败。

3、运行账号认证程序
运行命令onedrive -a,将返回的网址复制到浏览器打开,再登陆你的OneDrive for Business账号,登陆成功后复制地址栏中的地址(复制包括localhost的所有链接地址),粘贴到SSH客户端里,敲回车键即可。
请输入图片描述
如果返回以下字段:It seems like we have a refresh token, so we are ready to go,那就恭喜你,设置成功!

提示:如果你遇到bash: onedrive: command not found错误,则需要找到/usr/local/etc/OneDrive文件夹,修改onedrive和onedrive-d脚本,在第二行都加上export PATH=/usr/local/bin:$PATH代码,再保存就行了。

使用

1、使用命令

onedrive --help
 
#####################################################################
Usage: onedrive [OPTIONS] file1 [file2...]
       onedrive-d folder
 
Options:
  -d, --debug        Enable debug mode
  -a, --authorize    Run authorization process
  -f, --folder       Upload files into this remote folder
  -c, --creat        Creat remote folder."
                     Directory names are separated with a slash, e.g.
                     rootFolder/subFolder
                     Do NOT use a trailing slash!
  -h, --help         Show this help
  -r, --rename       Rename the files during upload
                     For each file you specify you MUST also specify
                     the remote filename as the subsequent parameter
                     Be especially careful with globbing!
  -s, --silent       Silent mode for use in crontab scripts.
                     Return only exit code.
  -ls,--list         Show the itmes in this directory.
  -l, --link         Show the file share link.
      
#####################################################################

2、命令示范
如果我们要上传/root文件夹里面的moerats.txt,使用命令:

#此命令默认上传到OneDrive根目录
onedrive '/root/moerats.txt'

#如果上传到指定文件夹,就需要加-f参数
onedrive -f RATS '/root/moerats.txt'  #上传到OneDrive根目录的RATS文件夹
onedrive -f RATS/RATS '/root/moerats.txt'  #上传到OneDrive根目录RATS文件夹里的RATS文件夹

如果我们要将/root文件夹及里面的文件夹和文件一起上传,使用命令:

#此命令默认上传到OneDrive根目录
onedrive-d '/root'

#如果上传到指定文件夹,就需要加-f参数
onedrive-d -f RATS '/root'  #上传到OneDrive根目录的RATS文件夹
onedrive-d -f RATS/RATS '/root'  #上传到OneDrive根目录RATS文件夹里的RATS文件夹

如果我们想直接查看OneDrive网盘目录的文件,使用命令:

#此命令只查看根目录文件
onedrive -l
#如果我们要查看根目录root文件夹里的文件
onedrive -l /root

请输入图片描述

Aria2自动上传

上传方法参考:使用Aira2下载文件后自动上传到Google Drive网盘

上传代码如下:

#!/bin/bash

GID="$1";
FileNum="$2";
File="$3";
MaxSize="15728640"
RemoteDIR="";  #上传到Onedrive的路径,默认为根目录,如果要上传到指定目录,方法看文章最后面。
LocalDIR="/home/www/download/";  #Aria2下载目录,记得最后面加上/

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(){
  IFS_BAK=$IFS
  IFS=$'\n'
  if [[ ! -d "$LocalDIR" ]]; then return; fi
  if [[ -e "$File" ]]; then
    if [[ $(dirname "$File") == $(readlink -f $LocalDIR) ]]; then
      ONEDRIVE="onedrive";
    else
      ONEDRIVE="onedrive-d";
    fi
    FileLoad="${File/#$LocalDIR}"
    while true
      do
        if [[ "$FileLoad" == '/' ]]; then return; fi
        echo "$FileLoad" |grep -q '/';
        if [[ "$?" == "0" ]]; then
          FileLoad=$(dirname "$FileLoad");
        else
          break;
        fi;
      done;
    if [[ "$FileLoad" == "$LocalDIR" ]]; then return; fi
    if [[ -n "$RemoteDIR" ]]; then
      Option=" -f $RemoteDIR";
    else
      Option="";
    fi
    EXEC="$(command -v $ONEDRIVE)";
    if [[ -z "$EXEC" ]]; then return; fi
    cd "$LocalDIR";
    if [[ -e "$FileLoad" ]]; then
      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$File \033[0mtoo large to spik.\n";
        return;
      fi
      eval "${EXEC}${Option}" \'"${FileLoad}"\';
      if [[ $? == '0' ]]; then
        rm -rf "$FileLoad";
      fi
    fi
  fi
  IFS=$IFS_BAK
}
LoadFile;

如果你想上传到指定的文件夹,修改如下:

#上传到Onedrive里的RATS目录,参数改为:RemoteDIR="RATS"; 
#上传到Onedrive里的RATS目录里的RATS目录,参数改为:RemoteDIR="RATS/RATS";

如果你觉得上传速度较慢,可以编辑/usr/local/etc/OneDrive/onedrive.cfg,修改threads线程数,默认2

#这里提供个快速修改线程数的命令,这里默认修改为5,建议别太高!
sed -i "s#max_upload_threads=2#max_upload_threads=5#g" '/usr/local/etc/OneDrive/onedrive.cfg'

文章参考:OneDrive for Business


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/697/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。