Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一下如何通过命令行的方式上传文件或文件夹 #266

Open
Xiaoph123 opened this issue Aug 25, 2024 · 6 comments
Open

Comments

@Xiaoph123
Copy link

如题
我有一个centos7的服务器,是最小化安装的版本,我如何通过命令上传文件或文件夹

@jamebal
Copy link
Owner

jamebal commented Aug 26, 2024

目前使用命令上传文件比较麻烦

@jamebal
Copy link
Owner

jamebal commented Aug 26, 2024

以下是使用 curl 命令上传文件的说明,表格中列出了每个参数的详细说明:

使用说明

使用此 curl 命令可以将本地文件上传到指定的网盘目录中。以下是每个参数的详细说明:

参数名称 必填 描述
url 必填 网盘地址,即上传文件的 API 端点。例如:http://192.168.0.192:7070/api/upload
relativePath 必填 文件名,包含文件的扩展名。例如:gui_1.2.3_aarch64.dmg
access-token 必填 访问令牌,可以在设置的应用授权中生成。例如:cd0950a31957dab4ac6f5ac9b097d351
username 必填 用户名,用于标识上传文件的用户。例如:username
currentDirectory 必填 要上传到网盘的目标目录路径。例如:/public
file 必填 本地文件的路径,指定要上传的文件。例如:@/Users/demo/Downloads/gui_1.2.3_aarch64.dmg
currentChunkSize 必填 填1
totalSize 必填 填1
filename 必填 填1

示例命令

curl --location --request POST 'http://192.168.0.192:7070/api/upload' \
--form 'currentChunkSize=1' \
--form 'totalSize=1' \
--form 'filename=1' \
--form 'relativePath=gui_1.2.3_aarch64.dmg' \
--header 'access-token: cd0950a31957dab4ac6f5ac9b097d351' \
--form 'username=username' \
--form 'currentDirectory=/public' \
--form 'file=@/Users/demo/Downloads/gui_1.2.3_aarch64.dmg'

注意事项

  • 网盘地址 (url):这是文件上传的 API 地址,必须填写正确的 URL。
  • 文件路径 (file):确保文件路径正确,路径前应带有 @ 符号以指示这是一个文件路径。
  • 令牌 (access-token):在网盘设置的“应用授权”中生成一个访问令牌,并将其用作请求头的一部分。
  • 目标目录 (currentDirectory):上传的文件将存储到此指定的网盘目录中。

填写好所有必填参数后,可以通过终端执行该命令,将指定的文件上传到网盘。

@jamebal
Copy link
Owner

jamebal commented Aug 26, 2024

有需要的话之后搞个命令行工具

@Xiaoph123
Copy link
Author

有需要的话之后搞个命令行工具

非常感谢您的帮助

@Xiaoph123
Copy link
Author

有需要的话之后搞个命令行工具

我觉得可以搞一个,因为有经常在服务器之间拷贝大文件,用云盘方便的多

@jamebal
Copy link
Owner

jamebal commented Dec 11, 2024

搞了一个上传文件的脚本,支持大文件上传
https://raw.githubusercontent.com/jamebal/jmal-cloud-server/refs/heads/master/upload.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants