Skip to content

Commit 7aebb1b

Browse files
authored
Update README.md
1 parent 17c93e7 commit 7aebb1b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,23 @@ public interface IUserApi
311311
`Task<byte[]>` | 原始响应二进制数据
312312
`Task<string>` | 原始响应消息文本
313313

314+
### 文件下载
315+
```
316+
public interface IUserApi
317+
{
318+
[HttpGet("/files/{fileName}"]
319+
Task<HttpResponseMessage> DownloadAsync(string fileName);
320+
}
321+
```
322+
323+
```
324+
using System.Net.Http
325+
326+
var response = await userApi.DownloadAsync('123.zip');
327+
using var fileStream = File.OpenWrite("123.zip");
328+
await response.SaveAsAsync(fileStream);
329+
```
330+
314331
### 接口声明示例
315332
#### Petstore接口
316333
这个OpenApi文档在[petstore.swagger.io](https://petstore.swagger.io/),代码为使用WebApiClientCore.OpenApi.SourceGenerator工具将其OpenApi文档反向生成得到

0 commit comments

Comments
 (0)