Giter Site home page Giter Site logo

upx's Introduction

upx is a tool for managing files in UPYUN. Mac, Linux, Windows supported

Test Build Lint Go Report Card GitHub tag (latest by date)

基本功能

  • 支持基本文件系统操作命令,如 mkdir, cd, ls, rm, pwd
  • 支持上传文件或目录到又拍云存储
  • 支持从又拍云存储下载文件或目录到本地
  • 支持增量同步文件到又拍云存储
  • 支持删除又拍云存储中的文件或目录,并且支持通配符 *
  • 支持多用户,多操作系统
  • 支持基于时间列目录以及删除文件
  • 支持 tree 获取目录结构
  • 支持提交异步处理任务
  • 更加准确简洁的进度条
  • 使用 UPYUN GoSDK v3
  • 同步目录支持 --delete
  • 支持 CDN 缓存刷新

安装

可执行程序二进制下载地址

源码编译

需要安装 Golang 编译环境

$ git clone https://github.com/upyun/upx.git
$ cd upx && make

or

$ go get -u github.com/upyun/upx/cmd/upx@master

Windows

PS> scoop bucket add carrot https://github.com/upyun/carrot.git
Install upx from github or upyun cdn:
PS> scoop install upx-github
PS> scoop install upx-upcdn

Docker

docker build -t upx .
docker run --rm upx upx -v

使用

所有命令都支持 -h 查看使用方法

命令 说明
login 登录又拍云存储
logout 退出帐号
sessions 查看所有的会话
switch 切换会话
info 显示服务名、用户名等信息
ls 显示当前目录下文件和目录信息
cd 改变工作目录(进入一个目录)
pwd 显示当前所在目录
mkdir 创建目录
tree 显示目录结构
get 下载一个文件或目录
put 上传一个文件或目录
upload 上传多个文件或目录或 http(s) 文件, 支持 Glob 模式过滤上传文件
mv 在同一 bucket 内移动文件
cp 在同一 bucket 内复制文件
rm 删除目录或文件
sync 目录增量同步,类似 rsync
auth 生成包含空间名操作员密码信息的 auth 字符串
post 提交异步处理任务
purge 提交 CDN 缓存刷新任务
global options 说明
--quiet, -q 不显示信息
--auth value auth 字符串
--help, -h 显示帮助信息
--version, -v 显示版本号

login

使用又拍云操作员账号登录服务, 登录成功后将会保存会话,支持同时登录多个服务, 使用 switch 切换会话。

需要提供的验证字段

  • ServiceName: 服务(bucket)的名称
  • Operator: 操作员名
  • Password: 操作员密码

语法

upx login

示例

upx login

#ServiceName: testService
#Operator:  upx
#Password: password

logout

退出当前登录的会话,如果存在多个登录的会话,可以使用 switch 切换到需要退出的会话,然后退出。

语法

upx logout

示例

upx logout

# Goodbye upx/testService ~

sessions

列举出当前登录的所有会话

语法

upx sessions

示例

upx sessions

# > mybucket1
# > mybucket2
# > mybucket3

switch

切换登录会话, 通过 sessions 命令可以查看所有的会话列表。

args 说明
service-name 服务名称(bucket)

语法

upx switch <service-name>

示例

upx switch mybucket3

info

查看当前服务的状态。

语法

upx info

示例

upx info
> ServiceName:   mybucket1
> Operator:      tester
> CurrentDir:    /
> Usage:         2.69GB

ls

默认按文件修改时间先后顺序输出

args 说明
remote-path 远程路径
options 说明
-d 仅显示目录
-r 文件修改时间倒序输出
--color 根据文件类型输出不同的颜色
-c v 仅显示前 v 个文件或目录, 默认全部显示
--mtime v 通过文件被修改的时间删选,参考 Linux find

语法

upx ls [options...] [remote-path]

示例

查看根目录下的文件

upx ls /

只查看根目录下的目录

upx ls -d /

只查看根目录下的修改时间大于3天的文件

upx ls --mtime +3 /

只查看根目录下的修改时间小于1天的文件

upx ls --mtime -1 /

cd

改变当前的工作路径,默认工作路径为根目录, 工作路径影响到操作时的默认远程路径。

args 说明
remote-path 远程路径

语法

upx cd <remote-path>

示例

将当前工作路径切换到 /www

upx cd /www

pwd

显示当前所在的远程目录

语法

upx pwd

示例

upx pwd

> /www

mkdir

创建远程目录

args 说明
remote-dir 远程目录

语法

upx mkdir <remote-dir>

示例

在当前工作目录下创建一个名为 mytestbucket 的目录

upx mkdir mytestbucket

在根目录下创建一个名为 mytestbucket 的目录

upx mkdir /mytestbucket

tree

显示目录结构,树形模式显示

语法

upx tree

示例

查看 /ccc 目录下的目录结构

upx tree /ccc
> |-- aaacd
> !   |-- mail4788ca.png
> |-- ccc
> !   |-- Eroge de Subete wa Kaiketsu Dekiru! The Animation - 02 (2022) [1080p-HEVC-WEBRip][8D1929F5].mkv
> !   |-- baima_text_auditer.tar
> !   |-- linux-1.txt

get

下载文件

args 说明
remote-path 远程路径,支持文件或文件夹
saved-file 需要保存到的本地目录,或指定完整的文件名
options 说明
-w 多线程下载 (1-10) (default: 5)
-c 恢复中断的下载
--start 只下载路径字典序大于等于 start 的文件或目录
--end 只下载路径字典序小于 end 的文件或目录

语法

upx get [options] <remote-path> [saved-file]

示例

下载文件

upx get /baima_text_auditer.tar

下载文件时指定保存路径

upx get /baima_text_auditer.tar ./baima_text_auditer2.tar

多线程下载文件

upx get -w 10 /baima_text_auditer.tar

恢复中断的下载

upx get -c /baima_text_auditer.tar

put

上传文件或文件夹

args 说明
local-file 本地的文件或文件夹
url 远端 url 文件
remote-file 需要保存到的远程文件路径或文件夹
options 说明
-w 多线程下载 (1-10) (default: 5)
-all 上传包含目录下隐藏的文件和文件夹

语法

upx put <local-file>|<url> [remote-file]

示例

上传本地文件,到远程绝对路径

upx put aaa.mp4 /video/aaa.mp4

上传本地目录,到远程绝对路径

upx put ./video /myfiles

上传 url 文件,到远程绝对路径

 upx put https://xxxx.com/myfile.tar.gz /myfiles

保存上传文件的错误日志

upx put . --err-log=err.log

upload

上传文件或目录,支持多文件,文件名匹配

args 说明
local-file 本地的文件或文件夹, 或匹配文件规则
remote-path 需要保存到的远程文件路径
options 说明
-w 多线程下载 (1-10) (default: 5)
-all 上传包含目录下隐藏的文件和文件夹
--remote 远程路径

语法

upx upload [--remote remote-path] <local-file>

示例

上传当前路径下的所有 jpg 图片到 /images 目录

upx upload --remote /images ./*.jpg

保存上传文件的错误日志

upx upload . --err-log=1.log

rm

默认不会删除目录,支持通配符 *

args 说明
remote-file 远程文件
options 说明
-d 仅删除目录
-a 删除目录跟文件
--async 异步删除,目录可能需要二次删除
--mtime v 参考 Linux find

语法

upx rm [options] <remote-file>

示例

删除目录 /www

upx rm -d /www

删除文件 /aaa.png

upx rm /aaa.png

mv

bucket 内部移动文件

args 说明
source-file 需要移动的源文件
dest-file 需要移动到的目标文件
options 说明
-f 允许覆盖目标文件

语法

upx mv [options] <source-file> <dest-file>

示例

移动文件

upx mv /aaa.mp4 /abc/aaa.mp4

移动文件,如果目标存在则强制覆盖

upx mv -f /aaa.mp4 /abc/aaa.mp4

cp

bucket 内部拷贝文件

args 说明
source-file 需要复制的源文件
dest-file 需要复制到的目标文件
options 说明
-f 允许覆盖目标文件

语法

upx mv [options] <source-file> <dest-file>

示例

移动文件

upx cp /aaa.mp4 /abc/aaa.mp4

复制文件,如果目标存在则强制覆盖

upx cp -f /aaa.mp4 /abc/aaa.mp4

sync

sync 本地路径 存储路径

args 说明
local-path 本地的路径
remote-path 远程文件路径
options 说明
-w 指定并发数,默认为 5
--delete 删除上一次同步后本地删除的文件

语法

upx sync <local-path> <remote-path>

示例

同步本地路径和远程路径

upx sync ./workspace /workspace

auth

生成包含空间名操作员密码信息, auth 空间名 操作员 密码

示例

当命令中包含 --auth 参数时,会忽略已登陆的信息。

生成 auth 字符串

upx auth mybucket user password

通过生成的 auth 字符串上传文件

upx --auth=auth-string put temp.file

post

options 说明
--app value app 名称
--notify value 回调地址
--task value 任务文件名

purge

purge url --list urls

options 说明
--list value 批量刷新文件名

TODO

  • put 支持断点续传
  • upx 支持指定 API 地址

upx's People

Contributors

arrebole avatar huangnauh avatar oott123 avatar polym avatar zccabb avatar zuohuadong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

upx's Issues

npx put命令相关

linux下
我在执行npx put file/ /的时候,会将file文件夹上传到云端 根目录,请问是否能只将file文件夹下的文件上传至云端根目录而不是file文件夹

很喜欢这种命令行工具,谢谢维护与更新

upx put 报错

错误信息

➜  data git:(master) upx put city.json
upanic: runtime error: index out of range [0] with length 0

goroutine 18 [running]:
github.com/gosuri/uiprogress.(*Bar).Bytes(0xc00019a200, 0xc000064180, 0xc00008c240, 0xc000046778)
	github.com/gosuri/[email protected]/bar.go:195 +0x525
github.com/gosuri/uiprogress.(*Bar).String(...)
	github.com/gosuri/[email protected]/bar.go:214
github.com/gosuri/uiprogress.(*Progress).print(0xc0000b2720)
	github.com/gosuri/[email protected]/progress.go:127 +0x9e
github.com/gosuri/uiprogress.(*Progress).Listen(0xc0000b2720)
	github.com/gosuri/[email protected]/progress.go:114 +0x45
created by github.com/gosuri/uiprogress.(*Progress).Start
	github.com/gosuri/[email protected]/progress.go:134 +0x3f

报错场景:
在使用 upx put上传文件夹的时候,发现报错,就手动单个上传文件,当执行到这个 city.json 文件的时候,报错再次出现,而其他的文件均正常上传,猜想是 upx 就此 json 文件识别为了配置文件,因此抛出了错误

关于 --delete 参数没有生效

环境:
使用的是 coding.net 提供的持续集成环境 ubuntu

upx 版本是 0.3.2

同步命令如下:

/upx/upx --auth ****** sync docs/.vuepress/dist/ / -w 50 --delete

按照我对文档中的说明理解(这里不知道是否理解正确)
--delete 参数会将上次同步后删除的文件删除

那么我每次构建项目,都会新生成全新的 js 文件,js 后面跟的 hash 不同,这里有输出:

+ ls -l docs/.vuepress/dist/assets/js/
total 1028
-rw-r--r-- 1 root root   2269 Jan 14 09:53 10.eee54edc.js
-rw-r--r-- 1 root root   1577 Jan 14 09:53 11.696307ce.js
-rw-r--r-- 1 root root  31715 Jan 14 09:53 12.917b4eaa.js
-rw-r--r-- 1 root root   2146 Jan 14 09:53 13.7aff667e.js
-rw-r--r-- 1 root root    995 Jan 14 09:53 14.0b9c3534.js
-rw-r--r-- 1 root root   1400 Jan 14 09:53 15.80d08ed2.js
-rw-r--r-- 1 root root   1790 Jan 14 09:53 16.5945bf0e.js
-rw-r--r-- 1 root root   1077 Jan 14 09:53 17.4b468caa.js
...

但是同步命令并未删除旧的的 js 文件

+ /upx/upx --auth ****** sync docs/.vuepress/dist/ / -w 50 --delete
sync /root/workspace/docs/.vuepress/dist/assets/js/53.48625820.js to /assets/js/53.48625820.js OK
sync /root/workspace/docs/.vuepress/dist/assets/js/10.eee54edc.js to /assets/js/10.eee54edc.js OK
sync /root/workspace/docs/.vuepress/dist/assets/js/37.3828e393.js to /assets/js/37.3828e393.js OK
sync /root/workspace/docs/.vuepress/dist/assets/js/14.0b9c3534.js to /assets/js/14.0b9c3534.js OK
...
...
+=============+=========+===========+================+===========+=============+
| SYNC_EXISTS | SYNC_OK | SYNC_FAIL | SYNC_NOT_FOUND | DELETE_OK | DELETE_FAIL |
+-------------+---------+-----------+----------------+-----------+-------------+
|           0 |     120 |         0 |              0 |         0 |           0 |
+-------------+---------+-----------+----------------+-----------+-------------+

我是在 upyun 的 web 上的文件管理中发现占用空间过大发现的,事实也的确如此,在 js 的目录下,存在多个版本的文件

文件名 文件类型 文件大小 更新时间 操作
10.041913dc.js application/javascript 1.54 KB 2021-01-13 11:56:12  
10.4e4aefb3.js application/javascript 30.97 KB 2021-01-12 22:33:17  
10.82219fb5.js application/javascript 30.97 KB 2021-01-12 14:23:27  
10.dec1ddf1.js application/javascript 30.97 KB 2021-01-07 00:42:23  
10.eee54edc.js application/javascript 2.22 KB 2021-01-14 09:13:37
10.efa08f3e.js application/javascript 30.97 KB 2021-01-11 00:24:28

现在能确定的是,每次构建会将旧的版本 js 文件清除掉,也就是说同步时只有最新版本的 js 文件,按照我的理解同步时会检查到目录下旧版本的文件被删除掉,但是并没有发生,这一点也能从 delete_ok = 0 发现

sync同步到根目录报错

$ ./upx sync ./public ./
sync /tmp/public to / FAIL mkdir /: POST 400 {"msg":"write file to fs error","code":40000012,"id":"09b7de4d7e80b24b984a472a69a205af"}


+=============+=========+===========+================+===========+=============+
| SYNC_EXISTS | SYNC_OK | SYNC_FAIL | SYNC_NOT_FOUND | DELETE_OK | DELETE_FAIL |
+-------------+---------+-----------+----------------+-----------+-------------+
|           0 |       0 |         1 |              0 |         0 |           0 |
+-------------+---------+-----------+----------------+-----------+-------------+

上传覆盖

使用 upx put file 不会覆盖之前的文件吗,通过 upx put --help 也未看到详细的参数详解

Feature: 上传时默认忽略隐藏的文件

用例

  • 用户上传目录时,目录中包含的 . 开头的文件默认会被忽略, windows隐藏属性的文件会被忽略
  • 用户可以使用 --all 参数 强制上传所以文件

文件删除后sync任然显示存在

我已经在控制台把文件和目录都删除了,但是upx sync任然显示文件存在
版本:upx version v0.3.5 linux/amd64 go1.15.8
另外我的文件发生了变动用sync也没有同步,是否可以增加文件对比更新功能?

希望增量同步添加忽略参数

像lftp是exclude-glob
或许我们也可以采取相同方式。

主要三大需求:忽略指定目录、忽略指定文件和忽略指定扩展名文件

Build failed in GO 1.6

I'm building upx in Ubuntu with Go version is 1.6, seem failed:

root@v:upx <master>#make
go get -v -d
go build -o upx
# github.com/polym/upx
./upx.go:55: cannot use func literal (type func(*cli.Context) error) as type func(*cli.Context) in field value
make: *** [all] Error 2

upload时-q未生效

COMMAND:upx -q upload --remote / path/to/files

使用--quiet也未生效

rm命令正常

是否考虑添加增量备份功能?

使用Get 命令下载时, 并发数使用默认的5, 但会出现429, too many request问题, 重新备份目录下文件时, 并不会判断本地已有该文件, 能否考虑添加增量备份功能?

checksum 验证不通过

我在使用过 Github Action 自动化配置的时候,出现如下报错:

go version go1.15.5 darwin/amd64
go: downloading github.com/upyun/upx v0.3.1
go get github.com/upyun/[email protected]: github.com/upyun/[email protected]: verifying module: checksum mismatch
	downloaded: h1:35mb9mGwj2KiNilJibpC3OzwHTXeAVhjQGWpv+gyb7k=
	sum.golang.org: h1:MGz1F4pkGTlV9HRs1ka2/lONoTVI076gBaKqx3x2nCE=

SECURITY ERROR
This download does NOT match the one reported by the checksum server.
The bits may have been replaced on the origin server, or an attacker may
have intercepted the download attempt.

For more information, see 'go help module-auth'.
Error: Process completed with exit code 1.

配置路径:https://github.com/flc1125/docs/blob/dc6c105ef437db10921e7bcb1f4db94d130e2c29/.github/workflows/deploy.yml#L28-L32

获取目录特殊字符错误

XRY1H%N3@2CWM_F.gif ERR doRESTRequest: parse /2012/02/UWMIO8XRY1H%N3@2CWM_F.gif: invalid URL escape "%N3"

upx get这个url的时候返回这个错误

Delete multiple File Support

Now, UPX only can delete one file by command delete

I think we need multiple file delete.

Just like this

image

I try to delete all file, but only delete first things.

建议更改 Release 文件名

目前尝试在 CI 环境中集成 upx 命令(docker 多平台构建), 遇到问题是当前 UPX 的 Release 并没有使用传统的 go 风格架构字符串, 例如 amd64arm64 等, 也没有使用 uname -m 的输出格式; 这导致必须借助一些脚本来做兼容判断.

当前 Release 发布物文件名称后缀似乎是当时根据 godownloader 生成的; 而项目内的 install.sh 已经完全不可用, 且 goreleaser 已停止维护; 是否考虑重新调整发布物文件名称或者修复自动安装脚本?

upx在网速慢的情况下,put文件夹经常会卡住

帮忙看下,网速慢的情况下,批量put一个文件夹内的文件,很大概率会卡住,类似下面这样
/huixuan/assets/M...ign-Iconic-Font.woff WAIT [--------------------------------------------------------------------] 0%
/huixuan/assets/fontawesome-webfont.svg WAIT [========================================================>-----------] 84%
/huixuan/assets/M...sign-Iconic-Font.ttf WAIT [--------------------------------------------------------------------] 0%
/huixuan/assets/M...gn-Iconic-Font.woff2 WAIT [--------------------------------------------------------------------] 0%
/huixuan/assets/fontawesome-webfont.eot WAIT [--------------------------------------------------------------------] 0%
/huixuan/assets/fontawesome-webfont.woff WAIT [--------------------------------------------------------------------] 0%

没上传完的文件等多久都不走进度,很大概率,导致我在网络稍差的情况下,文件没法更新,多次尝试总会卡在不同的地方,请帮忙解决,辛苦

最新的代码登录报signature error

git clone 最新的代码编译。

login 会爆:

login failed: usage: GET 401 {"msg":"signature error","code":40100005,"id":"606106d84090b725d1458e4fba69684b"}

Feature: 支持空间内移动和拷贝操作

upx 支持 movecopy 的方法, 仅适用于同一个 bucket 内部。

用例

用户可以移动云存储内部的文件

upx mv /aaa.mp4  /bbb/aac.mp4

用户可以拷贝云存储内部的文件

upx cp /aaa1.mp4 /bbb/aaa2.mp4

目标文件已存在,需要使用强制参数 -f 覆盖

upx mv -f /aaa.mp4  /bbb/aac.mp4

目标文件是目录,则会自动移动到目录

upx mv -f /aaa.mp4  /bbb/

超出范围

  • 用户无法移动和拷贝文件夹
  • 源文件不存在则无法继续操作

上传支持

上传的时候可以支持通配符 * 的方式上传一个文件夹下的所有文件吗?

upx sync 的返回值问题

写了一个 GitLab CI ,在 CI 的最后是将编译产生的文件同步到 UPYUN,但在同步时候可能因为某些原因出错,这是在所难免的,但是不知能不能当 fails 不为 0 时 os.Exit(-1) 之类的?

image

支持 cd -

目前 upx 不支持 cd - 的操作。cd - 可以回到上次所在目录。

upx sync

upx sync 不支持 rsync --delete 功能,请尽快开发,谢谢。

sync 只会上传本地有云上没有的文件,不会下载云上有本地没有的文件

我在本地设置有同步目录,同步目录下有云上不包含的文件夹 folder1;云存储中根目录下有本地不包含的文件夹 folder2;执行 upx sync 同步目录/ / 似乎只会将本地的 folder1 上传到又拍云,而不会下载 / 下的 folder2 到本地。这是这个程序的正常表现吗?如果是,我应该怎么样才能达到我所描述的效果?

用于登录该存储桶的操作员权限勾选了除了删除之外的权限。

此外,该程序的增量同步会考虑文件的修改吗(即文件名不变,内容发生变化);如果考虑,你们通过什么判断文件被修改?

操作系统:Windows11

sync方式下能否忽略目录

在win的cmd下,同步到远端的目录正常,但是有版本库目录不想同步,不知道有没有办法配置忽略
另外在Git shell下,sync完,远程目录会传到
sync E:\Server\www\testhome\dir to /D:/Program Files/Git/dir OK
sync E:\Server\www\testhome\t1f.txt to /D:/Program Files/Git/t1f.txt OK

同步目录问题

现在服务器上的目录结构是这样
要同步的目录在 /data/img 下

要同步的文件为
/00/01/0001123123123.jpg

我执行的操作为
cd /data/img

~/upx login
执行登录操作 登录成功

~/upx put ./* ./
执行文件上传 把当前目录下的文件全部上传到云储存跟目录

我的本意是要直接放在云存储的根目录 /00/01/0001123123123.jpg

结果上传上去的目录是 /01/01/0001123123123.jpg

请问是什么问题。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.