TA的每日心情 | 擦汗 昨天 09:02 |
---|
签到天数: 1046 天 连续签到: 4 天 [LV.10]测试总司令
|
本文仅仅是提供测试使用的代码。提供文件下载只需要返回 PhysicalFile 方法,如下面代码:
- [HttpGet]
- public IActionResult Get()
- {
- var folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
- var file = Path.Combine(folder, "big file");
- const string mime = "application/octet-stream";
- return PhysicalFile(file, mime);
- }
复制代码 本文的 big file 是程序运行创建的垃圾文件:
- private void WriteBigFile()
- {
- var folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
- var file = Path.Combine(folder, "big file");
- if (!File.Exists(file))
- {
- using (var stream = new FileStream(file, FileMode.Create))
- {
- for (int i = 0; i < 100000000; i++)
- {
- stream.WriteByte(0);
- }
- }
- }
- }
复制代码
|
|