Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
davidklassen committed Dec 30, 2016
1 parent 7700a83 commit c07ba20
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"clean": "rimraf build/*",
"copy": "cp project.json.tpl build/project.json",
"build": "npm run clean && npm run copy && webpack && chmod +x build/functions/**/*.bin",
"deploy": "npm run build && apex -C build deploy"
"deploy:apex": "apex -C build deploy",
"deploy": "npm run build && npm run deploy:apex"
},
"repository": {
"type": "git",
Expand Down
13 changes: 11 additions & 2 deletions src/functions/join/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Joins video chunks in one file.
*/


import λ from 'apex.js';
import AWS from 'aws-sdk';
import tmp from 'tmp';
Expand All @@ -8,19 +13,23 @@ const s3 = new AWS.S3();


export default λ(async (e) => {
// get list of chunks
const list = await s3.listObjectsV2({
Bucket: e.bucket,
Prefix: `${e.id}/chunks`
}).promise();

const parts = await Promise.all(list.Contents.map((item) => s3.getObject({
// download chunks
const chunks = await Promise.all(list.Contents.map((item) => s3.getObject({
Bucket: e.bucket,
Key: item.Key
}).promise()));

// concat and write to temp file
const file = tmp.fileSync({ postfix: '.webm' });
fs.appendFileSync(file.name, Buffer.concat(parts.map((part) => part.Body)));
fs.appendFileSync(file.name, Buffer.concat(chunks.map((part) => part.Body)));

// upload file to s3
return s3.upload({
Bucket: e.bucket,
Key: `${e.id}/joined.webm`,
Expand Down
5 changes: 5 additions & 0 deletions src/functions/reindex/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Repairs video container.
*/


import λ from 'apex.js';
import AWS from 'aws-sdk';
import tmp from 'tmp';
Expand Down
5 changes: 5 additions & 0 deletions src/functions/thumb/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Creates a thumbnail from a video file.
*/


import λ from 'apex.js';
import AWS from 'aws-sdk';
import tmp from 'tmp';
Expand Down
5 changes: 5 additions & 0 deletions src/functions/uuid/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Returns a V4 UUID.
*/


import λ from 'apex.js';
import uuidV4 from 'uuid/v4';

Expand Down
5 changes: 5 additions & 0 deletions src/utils/ffmpeg.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* ffmpeg command wrapper.
*/


import {exec} from 'child_process';
import ffmpegBin from '../../bin/ffmpeg';

Expand Down

0 comments on commit c07ba20

Please sign in to comment.