UDS(Unlimited Drive Storage):谷歌云盘无限容量存储

原理

将文件的二进制编码为base64并存入Google Docs中,下载时再从base64转为文件的二进制编码,从而还原文件。因为谷歌现在的政策是Google Docs(谷歌在线文档)是免费且不限制容量的,因此可以实现这一目的。当然,也不排除谷歌发现自己被薅羊毛之后添加限制或者解除Google Docs的unlimited storage政策,这是后话了。

Github项目地址:https://github.com/stewartmcgown/uds

部署

环境

环境:python3以上及其依赖,当然还需要国际互联网
安装python3和pip:

  • Linux:
yum install python3 pip3   apt install python3 python3-pip
  • macOS:
brew install python3

需要提前安装homebrew这个包管理器

以上也可以直接编译安装。

  • Windows:自己谷歌

关于缺失的依赖,缺什么装什么,例如:
如果报错ModuleNotFoundError: No module named ‘googleapiclient’,输入pip3 install --upgrade google-api-python-client即可

申请谷歌api
地址:https://developers.google.com/drive/api/v3/quickstart/python

申请好之后下载credentials.json文件备用。

Git clone并完成验证
以下步骤均在本机操作:

git clone https://github.com/stewartmcgown/uds.git
 
#注意这里一定要 cd 进目录,否则会报错‘Failed with: NoClientSecretError’
cd /path/to/uds
 
#移动刚刚下载好的 api 文件到 ups 文件夹并改名为 client_secret.json
mv /path/to/credentials.json /path/to/uds/client_secret.json
 
#初始化
python3 uds.py

完成之后会自动跳转到浏览器,并开始谷歌账户的验证和登录。在终端中也会出现跳转网站的网址:

浏览器出现「The authentication flow has completed.」即可。

这样就算完成了部署,下面可以开始使用了。该git clone动作可以在远端服务器上面完成,也可以直接在自己电脑上面完成。

在服务端部署的时候,需要手动复制网址到本机浏览器完成验证,验证完成后会给一串认证码。并使用python3 uds.py --noauth_local_webserver开始初始化步骤。

使用

python3 uds.py push     Uploads a file from this computer [path_to_file]
python3 uds.py bunch    Uploads files from this computer [word_in_file] [path_to_file]
python3 uds.py pull     Downloads a UDS file [id]
python3 uds.py batch    Downloads UDS files [word_in_file]
python3 uds.py grab     Downloads a UDS file [name]
python3 uds.py list     Finds all UDS files [query]
python3 uds.py update   Update cached UDS data
python3 uds.py delete   Deletes a UDS file [id]
python3 uds.py erase    Deletes a UDS file [name]
python3 uds.py wipe     Deletes UDS files [word_in_file]

解析: 抛开互联网网速,编码和解码也需要较长时间。因此该方法虽然可以做到无限容量,但是以传输和下载速度为代价,所以不建议大家上传大体积的文件。安全性来讲是很不错的,别人拿不到你的client_secret.json就别想解码下载了。大家看到最后一栏,list之后多出来了一个uds.py文件,那是我在远端服务器部署好之后尝试上传的。也证明了只要有client_secret.json文件在手,也可以实现跨设备上传和下载,网盘的标配功能。

不足:
uds core依然存在着不足,具体体现在:

  • 纯命令行需要掌握Linux基础,然而很多人只是想要一个无限容量的谷歌网盘
  • 程序对client_secret.json文件依赖性大,如何合理的托管是个问题
  • 跨设备下载和上传文件依然存在诸多不便(非自己电脑情况下),并且无法用一键傻瓜脚本解决
  • 没有分享功能,也不能转存他人文件
  • 需要国际互联网,这就意味着国内服务器不可以直接部署。

WEBgui

demo:传送门
项目地址:https://github.com/stewartmcgown/uds-web
作者为了解决可视化以及跨设备登录等问题开发了uds的web版,通过谷歌账号可以登录。

自己部署

screen -S uds-web
git clone https://github.com/stewartmcgown/uds-web.git
cd uds-web
npm install
npm run serve

截至19.9.2,该项目处于不可用状态,表现为:登录谷歌账号不需要账号密码,似乎没有写好?不能上传和下载任何文件,只是一个框架。

Related Post

发表回复