mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
added s3 server
This commit is contained in:
parent
4fc44b0929
commit
56dc9092e0
3 changed files with 63 additions and 0 deletions
1
examples/marketplace/S3Server/Procfile
Normal file
1
examples/marketplace/S3Server/Procfile
Normal file
|
@ -0,0 +1 @@
|
|||
web: node index.js
|
44
examples/marketplace/S3Server/index.js
Normal file
44
examples/marketplace/S3Server/index.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
var express = require('express');
|
||||
var app = express();
|
||||
var AWS = require('aws-sdk');
|
||||
var url = require('url');
|
||||
var querystring = require('querystring');
|
||||
var _ = require('underscore');
|
||||
|
||||
AWS.config.update({
|
||||
region: "us-east-1"
|
||||
});
|
||||
|
||||
var s3 = new AWS.S3();
|
||||
|
||||
app.set('port', (process.env.PORT || 5000));
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
var urlParts = url.parse(req.url)
|
||||
var query = querystring.parse(urlParts.query);
|
||||
|
||||
var params = {
|
||||
Bucket: "hifi-public",
|
||||
Marker: query.assetDir,
|
||||
MaxKeys: 10
|
||||
};
|
||||
s3.listObjects(params, function(err, data) {
|
||||
if (err) {
|
||||
console.log(err, err.stack);
|
||||
res.send("ERROR")
|
||||
} else {
|
||||
var keys = _.pluck(data.Contents, 'Key')
|
||||
res.send({
|
||||
urls: keys
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
app.listen(app.get('port'), function() {
|
||||
console.log('Node app is running on port', app.get('port'));
|
||||
})
|
||||
|
||||
|
||||
//ozan/3d_marketplace
|
18
examples/marketplace/S3Server/package.json
Normal file
18
examples/marketplace/S3Server/package.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "s3fileserver",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "eric",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"aws-sdk": "^2.2.15",
|
||||
"express": "^4.13.3",
|
||||
"querystring": "^0.2.0",
|
||||
"underscore": "^1.8.3",
|
||||
"url": "^0.11.0"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue