From f6ba817a266ce5c2a731be1a1be8aafefd0bec31 Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Sun, 7 Aug 2016 11:34:45 +0100 Subject: [PATCH] Remove sftp uploading --- api/routes/file.js | 1 - lib/hostr-file-stream.js | 7 ------- lib/uploader.js | 10 +--------- package.json | 1 + 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/api/routes/file.js b/api/routes/file.js index 25e3f0d..d87e67d 100644 --- a/api/routes/file.js +++ b/api/routes/file.js @@ -25,7 +25,6 @@ export function* post(next) { uploader.processingEvent(); - yield uploader.sendToSFTP(); yield uploader.processImage(); yield uploader.finalise(); diff --git a/lib/hostr-file-stream.js b/lib/hostr-file-stream.js index 0140816..3c17c96 100644 --- a/lib/hostr-file-stream.js +++ b/lib/hostr-file-stream.js @@ -1,7 +1,6 @@ import fs from 'fs'; import createError from 'http-errors'; import { get as getSFTP } from './sftp'; -import { get as getS3 } from './s3'; import debugname from 'debug'; const debug = debugname('hostr:file-stream'); @@ -35,12 +34,6 @@ export default function hostrFileStream(localPath, remotePath) { .then(resolve) .catch((err) => { debug('not on sftp', err); - writer(localPath, getS3(remotePath)) - .then(resolve) - .catch((s3err) => { - debug('not on s3'); - reject(s3err); - }); }); }); localRead.once('readable', () => { diff --git a/lib/uploader.js b/lib/uploader.js index 8bb4402..f4b6de5 100644 --- a/lib/uploader.js +++ b/lib/uploader.js @@ -9,7 +9,6 @@ import hostrId from './hostr-id'; import resize from './resize'; import malware from './malware'; import { sniff } from './type'; -import { upload as sftpUpload } from './sftp'; import debugname from 'debug'; const debug = debugname('hostr-api:uploader'); @@ -96,10 +95,6 @@ export default class Uploader { this.upload.resume(); } - sendToSFTP() { - return sftpUpload(join(storePath, this.path), join('hostr', 'uploads', this.path)); - } - acceptedEvent() { const acceptedEvent = `{"type": "file-accepted", "data": {"id": "${this.id}", "guid": "${this.tempGuid}", "href": "${baseURL}/${this.id}"}}`; @@ -190,10 +185,7 @@ export default class Uploader { const path = join(this.id[0], String(newSize.width), `${this.id}_${this.filename}`); debug('Writing file'); debug(join(storePath, path)); - return fs.writeFile(join(storePath, path), image).then(() => { - debug('Uploading file'); - return sftpUpload(join(storePath, path), join('hostr', 'uploads', path)); - }).catch(debug); + return fs.writeFile(join(storePath, path), image).catch(debug); }).catch(debug); } diff --git a/package.json b/package.json index 3a43418..766cab2 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "lwip": "0.0.9", "mime-types": "~2.1.5", "moment": "^2.13.0", + "mongodb": "^2.2.5", "mongodb-promisified": "~1.0.3", "mz": "^2.4.0", "node-fetch": "^1.5.3",