diff options
| -rw-r--r-- | bucky/util/federate.js | 21 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/index.js | 2 |
2 files changed, 12 insertions, 11 deletions
diff --git a/bucky/util/federate.js b/bucky/util/federate.js index 95c61c5..472c32e 100644 --- a/bucky/util/federate.js +++ b/bucky/util/federate.js @@ -1,5 +1,5 @@ var fetch = require('node-fetch') -const readFile = require('fs-readfile-promise') +const fs = require('fs') var db = require('../db') var upload = require('../util/upload') var mime = require('mime-types') @@ -60,8 +60,9 @@ module.exports = { return db.getFilesForThread(req.params.id) }).then(files => { var promises = files.map(file => { + copyFileToS3(file, thread_id) file.set('thread', thread_id) - storeFile(file) + file.set('storage', 'i.asdf.us') return send("file", file) }) return promises @@ -83,14 +84,17 @@ module.exports = { 'Accept': 'application/json', }, }).then((res) => {return res.json()}) + then((json) => console.log(json)) } - function storeFile(file){ + function copyFileToS3(file, thread_id){ // since for now we are essentially backing up local files, // upload them directly to s3 - const bucky_fn = file.get('thread') + '/' + file.get('filename') - readFile('public/data/' + bucky_fn) - .then(buffer => { - const remote_path = '/bucky/data/' + bucky_fn + const src_fn = file.get('thread') + '/' + file.get('filename') + const dst_fn = thread_id + '/' + file.get('filename') + fs.readFile('/Users/user/projects/bucky3/public/data/' + src_fn, (err, buffer) => { + if (err) return console.log(err) + const remote_path = '/bucky/data/' + dst_fn + console.log(mime.lookup(file.get('filename'))) upload.client().putBuffer(buffer, remote_path, { 'Content-Length': buffer.length, 'Content-Type': mime.lookup(file.get('filename')), @@ -111,9 +115,6 @@ module.exports = { console.error(err) s3res && s3res.resume && s3res.resume() }) - }).catch(e => { - console.error(e) - }) } } diff --git a/public/assets/js/lib/views/index/index.js b/public/assets/js/lib/views/index/index.js index fdc7a29..94bc57d 100644 --- a/public/assets/js/lib/views/index/index.js +++ b/public/assets/js/lib/views/index/index.js @@ -15,7 +15,7 @@ var IndexView = View.extend({ load: function(keyword){ if (keyword) { - $(".subtitle").html('<a href="/">< Home</a>') + $(".subtitle").html('<a href="/">< Home</a> · <a href="/keywords">Keywords</a>') this.threadbox.options.latest = false this.threadbox.options.welcome = false $.get(this.keywordAction + keyword, this.populate.bind(this)) |
