Skip to content
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

Node: Blob output binding should support passing a Buffer #232

Closed
mikhailshilkov opened this issue Jun 25, 2019 · 5 comments
Closed

Node: Blob output binding should support passing a Buffer #232

mikhailshilkov opened this issue Jun 25, 2019 · 5 comments

Comments

@mikhailshilkov
Copy link

What problem would the feature you're requesting solve? Please describe.

I'm running a Node.js Azure Function with an output Blob binding. I'm trying to save a binary file from a Buffer.

My binding:

{
  "name":"copy",
  "type":"blob",
  "direction":"out",
  "path":"files/copy-{name}",
  "connection":"StorageConnectionStringKey",
  "dataType":"binary"
}

Note that I tried dataType=binary but it doesn't seem to make any difference.

and in the function body:

return { copy: new Buffer("Hello") };

The blob contents is written as

{"type":"Buffer","data":[72,101,108,108,111]}

Describe the solution you'd like

It should save the data from the Buffer as-is. Hello in this case.

Related Issues

@eirikb
Copy link

eirikb commented Jul 8, 2019

@mikhailshilkov Have you tried using context.bindings instead of return?

context.bindings.copy = Buffer.from('Hello');

@mikhailshilkov
Copy link
Author

@eirikb I think I did but I can't remember for sure. Are you saying it works?

@eirikb
Copy link

eirikb commented Jul 8, 2019

Works for me when I did some tests. Using { copy: Buffer.from('Hello') } gave me same result as you. Also tried converting to Uint8Array and Uint32Array (I have to use the first one for binary data), but without success when using return.

@mikhailshilkov
Copy link
Author

@eirikb That's weird! Thank you, I'll give it a try.

@kashimiz kashimiz self-assigned this Jul 15, 2019
@kashimiz kashimiz transferred this issue from Azure/azure-functions-host Jul 15, 2019
@kashimiz kashimiz added this to the Triaged milestone Jul 15, 2019
@kashimiz kashimiz removed their assignment Jul 15, 2019
@kashimiz kashimiz added the bug label Jul 15, 2019
@mhoeger
Copy link
Contributor

mhoeger commented Nov 25, 2019

Fixing this with Functions V3. Thanks!

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

No branches or pull requests

4 participants