c# - dotnet core -> 返回 jpg 图像的 base64 字符串时 web api 内容类型的最佳实践
问题描述
[Route("image/{fileName}")]
[Produces("text/plain or what???")]
public string image(string fileName)
{
byte[] b = fromsomewhere();
return "data:image/jpg;base64," + Convert.ToBase64String(b);
}
我应该在产品中添加什么?
我应该在响应中包含“data:image/png;base64”,还是应该在客户端上设置?!
我也考虑过使用
public dynamic image(string fileName)
{
byte[] b = fromsomewhere();
return new FileContentResult(b, "image/jpg");
}
这是一种更简单的方法和工作,但我仍然很有趣应该为 base64string 设置什么内容类型......
解决方案
推荐阅读
- jenkins - 执行 Jenkinsfile 时如何获取管道配置字段“脚本路径”?
- ios - 如何在路径内部描边 uibezierpath 的边界?
- c# - SQL server - 在插入之前屏蔽/更改值唯一标识符
- html - 从primeng以角度实现日历时出错
- puppet - 测试木偶中未定义的事实
- python - 带有硒测试的 Django 频道 2 失败
- html - Bootstrap nav-justified 不占用全宽
- go - Windows 如何为 Golang 制作
- r - 比 r 中的 ifelse() 更快的函数
- intellij-idea - 在 IntelliJ 中启用自定义 CheckStyle