将一堆二进制文件像图像一样发送给用户:
interface API
{
@path("/data/image")
@contentType("image/png")
ubyte[] getImagePreview(string foo);
}该函数将返回一个包含ubyte[]值的Json数组
下面是我可以使用的属性列表:
adjustMethodStyle
bodyParam
contentType
extractHTTPMethodAndName
headerParam
method
noRoute
path
queryParam
rootPathFromName来源:Vibe.d site
唯一可以做这项工作的属性是contentType,据说它只适用于ubyte[]函数,这就是我使用的。
我遗漏了什么?
发布于 2019-07-26 19:08:37
您可以尝试使用非常简单的hunt框架:
@Action
Response image(string imageName)
{
return new FileResponse("/data/image/" ~ imageName);
}更多内容请阅读维基:https://github.com/huntlabs/hunt-framework/wiki/FileResponse
https://stackoverflow.com/questions/56787617
复制相似问题