Skip to content

Content is returned as { type: 'Buffer', data: [...] } with $return binding #3892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zavr-1 opened this issue Dec 14, 2018 · 1 comment
Open

Comments

@zavr-1
Copy link

zavr-1 commented Dec 14, 2018

With

import { readBuffer } from '@wrote/read' // returns a buffer

export default async () => {
    const body = await readBuffer('style.css')
    context.res = {
        body,
        headers: {
            'content-type': 'text/css',
        },
    }
}

and bindings

{
  "disabled": false,
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "route": "style.css",
      "direction": "in",
      "name": "req",
      "methods": [
        "get"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

my CSS file is served properly. When I change the bindings to use $return, I get served a buffer in serialised format:

    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
import { readBuffer } from '@wrote/read' // returns a buffer

export default async () => {
    const body = await readBuffer('style.css')
    return {
        body,
        headers: {
            'content-type': 'text/css',
        },
    }
}
{"type":"Buffer","data":[46,103,111,111]}

Azure Functions Core Tools (2.1.748 Commit hash: 5db2066)
Function Runtime Version: 2.0.12134.0

@mikhailshilkov
Copy link

I've hit the same issue today trying to return an image from my function. $return didn't work with a body buffer, while changing it to res worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants