# Writing buffer to file not writing correctly

**URL:** https://discourse.nodered.org/t/writing-buffer-to-file-not-writing-correctly/23132
**Category:** General
**Created:** [15 March 2020 10:45 UTC](https://discourse.nodered.org/t/writing-buffer-to-file-not-writing-correctly/23132 "2020-03-15T10:45:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![albydnc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/albydnc/32/8878_2.png) [@albydnc](https://discourse.nodered.org/u/albydnc)
#### Post date: [15 March 2020 10:45 UTC](https://discourse.nodered.org/t/writing-buffer-to-file-not-writing-correctly/23132/1 "2020-03-15T10:45:27Z")

</div>

I am trying to write a buffer coming from a wav audio file to file.  
By using an HTTP endpoint and then saving it from there, I get the file fully working.  
By saving it using the File Node in binary encoding, it gets messed up and it is different from the buffer that originated it.

Here is a test flow (thanks to @BartButenaers) :

```auto
[{"id":"4feed947.cded28","type":"file in","z":"b3db206e.b7139","name":"","filename":"/tmp/test.wav","format":"","chunk":false,"sendError":false,"encoding":"none","x":410,"y":620,"wires":[["5c99ef16.93d88"]]},{"id":"57de7ec8.184eb","type":"inject","z":"b3db206e.b7139","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":620,"wires":[["4feed947.cded28"]]},{"id":"5c99ef16.93d88","type":"play audio","z":"b3db206e.b7139","name":"","voice":"9","x":590,"y":620,"wires":[]},{"id":"a833df3d.c5369","type":"file","z":"b3db206e.b7139","name":"","filename":"/tmp/test.wav","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"binary","x":590,"y":520,"wires":[[]]},{"id":"359ebe7c.62df62","type":"inject","z":"b3db206e.b7139","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":520,"wires":[["85018a22.774868"]]},{"id":"85018a22.774868","type":"http request","z":"b3db206e.b7139","name":"","method":"GET","ret":"bin","paytoqs":false,"url":"http://mauvecloud.net/sounds/pcm0811m.wav","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":520,"wires":[["a833df3d.c5369"]]},{"id":"3bc85905.fa6366","type":"comment","z":"b3db206e.b7139","name":"Step 1 : download the WAV file and store it in a file","info":"","x":350,"y":480,"wires":[]},{"id":"8231499.8dfecb8","type":"comment","z":"b3db206e.b7139","name":"Step 2 : play the downloaded WAV file","info":"","x":310,"y":580,"wires":[]}]

```

[Here the issue I opened before](https://discourse.nodered.org/t/exported-audio-wav-file-is-distorted/23115)

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [15 March 2020 11:10 UTC](https://discourse.nodered.org/t/writing-buffer-to-file-not-writing-correctly/23132/2 "2020-03-15T11:10:00Z")

</div>

seems to work fine if I just select "default" encoding

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9c28673ec16c0a561112c66b8bfc585452e62c14.png)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [14 May 2020 11:11 UTC](https://discourse.nodered.org/t/writing-buffer-to-file-not-writing-correctly/23132/3 "2020-05-14T11:11:42Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
