Sending a bunch of binary back to the user like an image:
interface API
{
@path("/data/image")
@contentType("image/png")
ubyte[] getImagePreview(string foo);
}
The function is returning a Json
array with the values of the ubyte[]
Here are the list of attributes I can use:
adjustMethodStyle
bodyParam
contentType
extractHTTPMethodAndName
headerParam
method
noRoute
path
queryParam
rootPathFromName
Source: Vibe.d site
The only attribute that can do the job is contentType
and it's said there that it only works with ubyte[]
functions, and that's what I used.
What am I missing?
You can try hunt framework so easy use:
@Action
Response image(string imageName)
{
return new FileResponse("/data/image/" ~ imageName);
}
More read wiki: https://github.com/huntlabs/hunt-framework/wiki/FileResponse
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.