Created
April 4, 2011 00:46
-
-
Save easylogic/900983 to your computer and use it in GitHub Desktop.
implements file upload in zappa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it is so simple. | |
it is that add connect-form in zappa | |
1. npm install zappa | |
2. npm install connect-form | |
3. cd /usr/local/lib/node/.npm/zappa/active/package/lib - move yourself npm directory | |
4. edit zappa.coffee | |
zappa = exports | |
express = require 'express' | |
form = require 'connect-form' <--- append connect-form module | |
fs = require 'fs' | |
puts = console.log | |
5. set http server | |
@http_server.use express.bodyParser() | |
@http_server.use express.cookieParser() | |
@http_server.use express.session(secret: 'hackme' ) | |
@http_server.use form(keepExtensions: true) <-------- append connect-form middleware | |
6. coffee -c zappa.coffee | |
it is done to implements file-upload in zappa | |
7. use connect-form in zappa | |
post '/': -> | |
request.form.complete (err, fields, files) -> | |
if not err | |
// saveGridFS file.filename for filekey, file of files | |
next() | |
else | |
next() | |
request.form.on 'progress', (bytesReceived, bytesExpected) -> | |
percent = (bytesReceived / bytesExpected * 100) | 0 | |
process.stdout.write 'Uploading: %' + percent + "\n" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment