fs.writeFile()

73 views
Skip to first unread message

Donald Organ

unread,
Apr 19, 2012, 1:09:25 PM4/19/12
to sil...@googlegroups.com
I am trying to write a file to the file system and it seems no matter what I do fw.writeFile() returns false

I am using an absolute path and the folder I am trying to write to is owned by the same user that is running httpd-silk.js


Ideas?

Michael Schwartz

unread,
Apr 19, 2012, 2:07:34 PM4/19/12
to sil...@googlegroups.com
I've never seen it fail if it could actually write to an existing directory. I didn't test it after filling up my hard drive or anything like that tho (would cause an error).

Eric Dykstra

unread,
Oct 7, 2013, 10:04:26 AM10/7/13
to sil...@googlegroups.com
Donald,

I have a different issue. I am writing to the file system, but only a very small part of the file data gets written.

There is a line in the SilkJS docs that makes me think I am misunderstanding something.

On the page: http://silkjs.net/http-server/ is says; "For POST data that is a file upload, the value is a hash containing information about the file, and the base64 encoded file data.". I am sending the binary data using POST, but in it's own variable. The above sentence implies it should be done differently? I guess I am 'grabbing at straws' here maybe.

If I do this,

    console.dir(file_data); // This dumps a lot of data.
    var success = fs.writeFile64(file_spec, file_data); // This does create a file, albeit corrupt.
    console.log(success); 

success comes back true, and the file contains sometimes as little as 50 bytes.

Assuming you got this resolved, would you have a code snippet showing how you receive the data file on the SilkJS side? I am probably doing something 'simple' wrong. An example will help me see it.

Thanks!

Eric

Donald Organ

unread,
Oct 7, 2013, 5:25:04 PM10/7/13
to sil...@googlegroups.com
why are you passing binary data, why not just upload the file via a form and let it be handled.  It sounds like maybe there is a max on POST size.


--
You received this message because you are subscribed to the Google Groups "SilkJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silkjs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages