0

像图像一样向用户发送一堆二进制文件:

interface API
{
  @path("/data/image")
  @contentType("image/png")
  ubyte[] getImagePreview(string foo);
}

该函数返回一个Json数组,其中包含ubyte[]

以下是我可以使用的属性列表:

adjustMethodStyle
bodyParam
contentType
extractHTTPMethodAndName
headerParam
method
noRoute
path
queryParam
rootPathFromName

资料来源:Vibe.d 网站

唯一可以完成这项工作的属性是contentType,据说它只适用于ubyte[]函数,这就是我使用的。

我错过了什么?

4

1 回答 1

0

你可以试试hunt framework这么简单的使用:

    @Action
    Response image(string imageName)
    {
        return new FileResponse("/data/image/" ~ imageName);
    }

更多阅读维基: https ://github.com/huntlabs/hunt-framework/wiki/FileResponse

于 2019-07-26T11:08:36.950 回答