Skip to content

Commit

Permalink
updated app
Browse files Browse the repository at this point in the history
  • Loading branch information
grippy committed Mar 16, 2010
1 parent 94fccc8 commit a268d70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 11 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>'
);
Expand Down Expand Up @@ -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>'+
Expand Down
4 changes: 3 additions & 1 deletion aws/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down

0 comments on commit a268d70

Please sign in to comment.