0

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?

Qurashi
  • 1,449
  • 16
  • 27

1 Answers1

0

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