On Saturday, June 22, 2013 9:35:17 AM UTC-4, yu sun wrote:
> I'm working on file uploading and want to chunk upload files to the
> server, but when i combined the chunked files, the file hash changed(diff
> from the orignal hash). There might be some mistakes. Please help. thx thx.
>
Why chunk them manually? Just let the streams worry about chunking and just
do for the client side:
function putFile(fileStat) {
var req = createRequest('/testfiles', 'PUT', { 'Content-Length':
fileStat.fileSize });
fs.createReadStream(fileStat.filePath).pipe(req);
}
and for the server side:
exports.put = function(req, res) {
// assuming getFilePath() returns a sanitized path ...
var ws = fs.createWriteStream(getFilePath());
ws.on('finish', function() {
res.status(200);
res.end('uploaded file');
});
req.pipe(ws);
};
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.