1. 导入(上传文件)

方法一:用 VS Code 的 REST Client 插件

1. 安装 REST Client 插件。
2. 在 `backend/.vscode` 或 backend 目录下新建 `test.http` 文件,写入如下内容:

```
### 导入Excel
POST http://localhost:8089/document/import/excel
Content-Type: multipart/form-data

file=@C:/绝对路径/你的文件.xlsx

### 导入CSV
POST http://localhost:8089/document/import/csv
Content-Type: multipart/form-data

file=@C:/绝对路径/你的文件.csv

### 导入PDF
POST http://localhost:8089/document/import/pdf
Content-Type: multipart/form-data

file=@C:/绝对路径/你的文件.pdf

### 导入Word
POST http://localhost:8089/document/import/word
Content-Type: multipart/form-data

file=@C:/绝对路径/你的文件.docx
```

3. 鼠标悬停在 `POST ...` 行左侧的 `Send Request`,点击即可上传并查看返回内容。

---

方法二:用 Postman

1. 新建请求,选择 POST,地址如 `http://localhost:8089/document/import/csv`
2. Body 选择 `form-data`,key 填 `file`,类型选 File,选择你的文件。
3. 发送请求,查看返回内容。

---

2. 导出(下载文件)

方法一:浏览器直接访问

在浏览器地址栏输入:

- Excel: `http://localhost:8089/document/export/excel`
- CSV: `http://localhost:8089/document/export/csv`
- PDF: `http://localhost:8089/document/export/pdf`
- Word: `http://localhost:8089/document/export/word`

回车后浏览器会自动下载对应文件。

---

方法二:用 REST Client 插件

在 `test.http` 文件中写:

```
### 导出Excel
GET http://localhost:8089/document/export/excel

### 导出CSV
GET http://localhost:8089/document/export/csv

### 导出PDF
GET http://localhost:8089/document/export/pdf

### 导出Word
GET http://localhost:8089/document/export/word
```

点击 `Send Request`,右侧会有下载按钮。

注意:

  1. 端口号(如8089)请根据你实际项目端口调整。
  2. 文件路径要用绝对路径,且文件需真实存在。

 

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐