-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use dynamodb to store featured picture per picset as well as all the …
…pics with face information.
- Loading branch information
Showing
7 changed files
with
127 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.idea | ||
node_modules | ||
photos | ||
_site | ||
.sass-cache | ||
npm-debug.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
# finpics | ||
Use AWS Rekognition to provide a faces search of finpics.com | ||
|
||
## DynamoDB | ||
### pics table | ||
* primaykey (Primary Key) | ||
* sortKey (Sort Key) | ||
* ... Rekognition IndexFaces response | ||
|
||
*Picsets* | ||
* primaykey: '/' (Primary Key) | ||
* sortkey: '014_newportboston' (Sort Key) | ||
* pic: 'Newport_pic_3.jpg' | ||
|
||
*Pics* | ||
* primaykey: '014_newportboston' (Primary Key) | ||
* sortkey: 'Newport_pic_3.jpg' (Sort Key) | ||
* ... Rekognition IndexFaces response | ||
|
||
## Develop locally | ||
npm install local-web-server | ||
ws | ||
npm run serve | ||
|
||
## Deploy | ||
Install AWS CLI and configure profile credentials. | ||
|
||
### Web Assets | ||
aws s3 sync . s3://finpics.com --exclude "photos/*" --exclude ".gitignore" --exclude ".idea/*" --exclude ".git/*" --exclude "util/*" --exclude "node_modules/*" --exclude "package.json" --dryrun --storage-class REDUCED_REDUNDANCY --profile bluefin | ||
npm run deploy-site | ||
|
||
### Photos | ||
aws s3 sync . s3://finpics-pics --exclude "*" --include "photos/*" --storage-class REDUCED_REDUNDANCY --profile bluefin | ||
npm ren deploy-pics |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var winston = require('winston'); | ||
var _ = require('lodash'); | ||
var async = require('async'); | ||
var AWS = require('aws-sdk'); | ||
|
||
var docClient = new AWS.DynamoDB.DocumentClient(); | ||
|
||
var functions = {}; | ||
|
||
// | ||
// Handles DynamoDB calls. | ||
// | ||
functions.query = function(callback) { | ||
var params = { | ||
TableName: 'pics', | ||
KeyConditionExpression: "primarykey = :primarykey", | ||
ExpressionAttributeValues: { | ||
":primarykey": '/' | ||
} | ||
}; | ||
winston.debug(JSON.stringify(params)); | ||
docClient.query(params, function(err, data) { | ||
if (err) winston.error(err); | ||
callback(err, data); | ||
}); | ||
}; | ||
|
||
functions.query(function(err, data) { | ||
winston.info(JSON.stringify(data, null, 3)); | ||
}); |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var winston = require('winston'); | ||
var _ = require('lodash'); | ||
var async = require('async'); | ||
var AWS = require('aws-sdk'); | ||
|
||
var docClient = new AWS.DynamoDB.DocumentClient(); | ||
|
||
var functions = {}; | ||
|
||
// | ||
// Handles DynamoDB calls. | ||
// | ||
functions.put = function(folder, image, callback) { | ||
var params = { | ||
TableName: 'pics', | ||
Item: { | ||
primarykey: '/', | ||
sortkey: folder, | ||
pic: image | ||
} | ||
}; | ||
winston.debug(JSON.stringify(params)); | ||
docClient.put(params, function(err, data) { | ||
if (err) winston.error(err); | ||
callback(err); | ||
}); | ||
}; | ||
|
||
var picset_images = require('./picset-images.json'); | ||
async.eachSeries(picset_images, function(image, next){ | ||
var split = _.split(image, '/'); | ||
functions.put(split[0], split[2], next); | ||
}, function(err) { | ||
winston.info('Done'); | ||
}); |