Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

File upload example #21

Open
mm765 opened this issue Dec 8, 2016 · 4 comments
Open

File upload example #21

mm765 opened this issue Dec 8, 2016 · 4 comments

Comments

@mm765
Copy link

mm765 commented Dec 8, 2016

The example http-test2 seems to be not working here. it can't even find the require'd 'fs'.
I believe 'fs' has been renamed to File is that correct ?
If so, File has a slightly different interface, so the example still won't work.

But my main question actually is:
there is a comment in there stating "tested with binary and text uploads." and i wanted to know if that really was the case or if this was an example copied from somewhere else and never converted to decaf ?

Thanks in advance,
Matthias

@mschwartz
Copy link
Contributor

mschwartz commented Dec 9, 2016 via email

@mm765
Copy link
Author

mm765 commented Dec 9, 2016

There is a fs.js as builtin but it has only 4 methods: isFile, isDir, realpath and readFile.
The writeFile method in the File module doesnt take a filename as a first parameter but only the content, append flag and an encoding).
i searched for a few hours now and i'm at my wits end. The only thing i can think of is that you had another fs.js somewhere which got included because require.js has some predefined paths:
/**
* This is an array of file system paths that are searched for modules when require() is called. These may be relative to the current directory where decaf is launched, or absolute paths.
* @Property
*
* @type {Array}
*/
require.paths = [
'bower_components',
'bower_components/decaf/modules',
'node_modules',
'modules',
'/usr/local/decaf',
'/usr/local/decaf/modules',
'./'
];

Do you think it might be possible that there was another fs.js in one of those paths on your system and you accidentally used that one ?

@mschwartz
Copy link
Contributor

mschwartz commented Dec 10, 2016 via email

@mm765
Copy link
Author

mm765 commented Dec 12, 2016

I found the problem. The post data is read into a "latin1" encoded string but the writefile was done without any specific encoding, so it used the system encoding which in my case is UTF-8.

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

No branches or pull requests

2 participants