Permalink
Browse files

updated app

  • Loading branch information...
1 parent 94fccc8 commit a268d703ce518054e60c9b3688b9f628ed3da80b grippy committed Mar 16, 2010
Showing with 15 additions and 8 deletions.
  1. +1 −1 README
  2. +11 −6 app.js
  3. +3 −1 aws/s3.js
View
2 README
@@ -8,7 +8,7 @@ The above link should hopefully provide some insight on how this app might be us
== Requirements ==
-'bastard samurai' http://www.youtube.com/watch?v=TZuo3ryNFPk
--nodejs >= 0.1.31 (actually only tested on 0.1.31)
+-nodejs = 0.1.31 (tested on 0.1.31)
== Configuration ==
Just edit config.js and place your own configuration values into each of the possible environment variables.
View
17 app.js
@@ -203,10 +203,15 @@ function display_form(req, res) {
'<html>'+
'<head></head>'+
'<body>'+
+ '<a href="/buckets">View buckets</a>' +
+ ' | <a href="/create_bucket">Create bucket</a>' +
+ '<hr />' +
'<form action="/upload" method="post" enctype="multipart/form-data">'+
+ 'Upload to ' +
+ s3.url(bucket) +
'<input type="file" name="upload-file" />'+
'<input type="submit" value="Upload" />'+
- '</form>'+
+ '</form>'+
'</body>'+
'</html>'
);
@@ -245,21 +250,21 @@ function upload_file(req, res) {
chunks.push(chunk)
}
});
-
+
mp.addListener("complete", function() {
+ // remember, this process only shows one file upload. adjust accordingly.
+ // options: streaming to disk first, then write to s3 in the callback (copy the s3 call below).
// var path = "./uploads/" + filename
// fs.writeFile(path, chunks.join(''), 'binary', function(err, written){
// log('binary gods obey')
// })
-
+ // streaming to s3
filename = Math.floor((Math.random() * 1024)).toString() + '_' + filename
- var file = {'name': filename, 'path':'./uploads/', 'content_type': content_type, 'data': chunks.join('')};
+ var file = {'name': filename, 'content_type': content_type, 'data': chunks.join('')};
var args = {'bucket': bucket, 'file':file};
s3.upload(args, function(data){
log("upload to s3 finished")
- // log(sys.inspect(data))
-
var response = '<html>'+
'<head></head>'+
'<body>'+
View
@@ -35,7 +35,9 @@ exports.init = function(args) {
}
exports.url = function(bucket, object) {
- return "http://" + this.config.host + '/' + bucket + '/' + object
+ var url = "http://" + this.config.host + '/' + bucket + '/';
+ if (object != undefined) url += object;
+ return url
}

0 comments on commit a268d70

Please sign in to comment.