在开发中,网站或者一些安装包等需要用户下载的文件,最好的方式就是放在公有云 CDN 中,常用的公有云 CDN 包括七牛云、又拍云、阿里云等,今天介绍的是使用又拍云的 CDN 内容存储。
查看官方文档,管理存储内容可以使用又拍云官网的网页版管理工具、curl或者 Form 表单的方式来管理,作为开发者而言更方便的是使用命令行的管理工具 upx
。
来自官方的介绍说:
upx is a tool for managing files in UPYUN. Mac, Linux, Windows supported
我们从 GitHub 中查看 upx
的项目主页,它支持常用的 Windows
、Linux
、macOS
系统。
以下是我基于 macOS
系统为例介绍 upx
的使用:
-
下载
upx
的可执行文件
从项目的版本下载页中下载最新的版本
-
将下载的压缩包解压,在文件夹中可以看到可执行文件
upx
(在Windows
系统中是.exe
文件) -
将可执行文件放置到系统环境变量中;或者在
Linux
或者macOS
系统中,为可执行文件添加系统链接,比如我的可执行文件都放置在了~/Documents/software
文件夹中ln -s ~/Documents/software/upx_0.3.5_Darwin_x86_64/upx /usr/local/bin/upx
-
然后在终端中输入
upx --help
看到帮助信息输出,即证明已经配置成功➜ ~ upx -h NAME: upx - a tool for driving UpYun Storage USAGE: upx [global options] command [command options] [arguments...] VERSION: v0.3.5 darwin/amd64 go1.15.8 AUTHOR: Hongbo.Mo <zjutpolym@gmail.com> COMMANDS: login Log in to UpYun logout Log out of your UpYun account sessions List all sessions switch Switch to specific session info Current session information cd Change directory pwd Print working directory mkdir Make directory ls List directory or file tree List contents of directories in a tree-like format get Get directory or file put Put directory or file rm Remove directory or file sync Sync local directory to UpYun auth Generate auth string post Post async process task purge refresh CDN cache get-db get db value upgrade upgrade upx to latest version help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --quiet, -q not verbose --auth value auth string --help, -h show help --version, -v print the version
-
登录到
upyun
# 输入服务名即:budget # 输入操作员名称(注意不是又拍云账户) # 输入操作员密码:(注意不是又拍云的账户密码) upx login
-
查看又拍云的服务信息
upx info
-
上传文件到又拍云
upx put 本地文件/目录 远程文件/目录
-
以树形方式查看存储的文件
upx tree
-
删除文件
upx rm 删除的文件/目录
-
退出登录
upx logout
更多内容
前端开发转全栈,目前的技术栈是 Node.js、Python,日常研究 C、C++ 和 Rust,孜孜啃食系统开发和网络设计中~
更多的内容请移步GitHub@ruxf,知乎@如小非,掘金@如小非,或者关注我的公众号@全栈开发师,欢迎来撩~
学到老,写到老,生命不停,编程不止~
加油,打工人~