summaryrefslogtreecommitdiff
path: root/src/api/endpoints
diff options
context:
space:
mode:
authorotofune <otofune@gmail.com>2017-11-14 03:47:42 +0900
committerotofune <otofune@gmail.com>2017-11-14 03:47:42 +0900
commite56f716a89227c76dfc05e48b3ca438f766f85b4 (patch)
treec174de080e1b94d1b5dc8b42fd6822a6be0c668f /src/api/endpoints
parentadd-file-to-drive - Promise百烈拳とメモリ削減 (diff)
downloadsharkey-e56f716a89227c76dfc05e48b3ca438f766f85b4.tar.gz
sharkey-e56f716a89227c76dfc05e48b3ca438f766f85b4.tar.bz2
sharkey-e56f716a89227c76dfc05e48b3ca438f766f85b4.zip
format
Diffstat (limited to 'src/api/endpoints')
-rw-r--r--src/api/endpoints/drive/files/upload_from_url.ts38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/api/endpoints/drive/files/upload_from_url.ts b/src/api/endpoints/drive/files/upload_from_url.ts
index 9c759994e0..60332b4afe 100644
--- a/src/api/endpoints/drive/files/upload_from_url.ts
+++ b/src/api/endpoints/drive/files/upload_from_url.ts
@@ -12,7 +12,7 @@ import * as fs from 'fs';
import * as request from 'request';
import * as crypto from 'crypto';
-const log = debug('misskey:endpoint:upload_from_url')
+const log = debug('misskey:endpoint:upload_from_url');
/**
* Create a file from a URL
@@ -39,54 +39,54 @@ module.exports = (params, user) => new Promise((res, rej) => {
// Create temp file
new Promise((res, rej) => {
tmp.file((e, path) => {
- if (e) return rej(e)
- res(path)
- })
+ if (e) return rej(e);
+ res(path);
+ });
})
// Download file
.then((path: string) => new Promise((res, rej) => {
- const writable = fs.createWriteStream(path)
+ const writable = fs.createWriteStream(path);
request(url)
.on('error', rej)
.on('end', () => {
- writable.close()
- res(path)
+ writable.close();
+ res(path);
})
.pipe(writable)
- .on('error', rej)
+ .on('error', rej);
}))
// Calculate hash & content-type
.then((path: string) => new Promise((res, rej) => {
- const readable = fs.createReadStream(path)
- const hash = crypto.createHash('md5')
+ const readable = fs.createReadStream(path);
+ const hash = crypto.createHash('md5');
readable
.on('error', rej)
.on('end', () => {
- hash.end()
- res([path, hash.digest('hex')])
+ hash.end();
+ res([path, hash.digest('hex')]);
})
.pipe(hash)
- .on('error', rej)
+ .on('error', rej);
}))
// Create file
.then((rv: string[]) => new Promise((res, rej) => {
- const [path, hash] = rv
+ const [path, hash] = rv;
create(user, {
stream: fs.createReadStream(path),
name,
hash
}, null, folderId)
.then(driveFile => {
- res(driveFile)
+ res(driveFile);
// crean-up
fs.unlink(path, (e) => {
- if (e) log(e.stack)
- })
+ if (e) log(e.stack);
+ });
})
- .catch(rej)
+ .catch(rej);
}))
// Serialize
.then(serialize)
.then(res)
- .catch(rej)
+ .catch(rej);
});