summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-11-14 05:40:35 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-11-14 05:40:35 +0900
commiteaeb27f3d1bb989814829461c097ac8be0822462 (patch)
treeb2435b9849090f28c69b72f54d3e4b67d5e90a64 /src
parent#914 (diff)
parentMerge pull request #915 from syuilo/write-file-use-stream (diff)
downloadsharkey-eaeb27f3d1bb989814829461c097ac8be0822462.tar.gz
sharkey-eaeb27f3d1bb989814829461c097ac8be0822462.tar.bz2
sharkey-eaeb27f3d1bb989814829461c097ac8be0822462.zip
Merge branch 'master' of https://github.com/syuilo/misskey
Diffstat (limited to 'src')
-rw-r--r--src/api/common/add-file-to-drive.ts27
-rw-r--r--src/api/server.ts2
2 files changed, 15 insertions, 14 deletions
diff --git a/src/api/common/add-file-to-drive.ts b/src/api/common/add-file-to-drive.ts
index 7defbc631a..9ed5e88744 100644
--- a/src/api/common/add-file-to-drive.ts
+++ b/src/api/common/add-file-to-drive.ts
@@ -40,7 +40,7 @@ const addFile = async (
folderId: mongodb.ObjectID = null,
force: boolean = false
) => {
- log(`registering ${name} (user: ${user.username})`);
+ log(`registering ${name} (user: ${user.username}, path: ${path})`);
// Calculate hash, get content type and get file size
const [hash, [mime, ext], size] = await Promise.all([
@@ -210,18 +210,19 @@ export default (user: any, file: string | stream.Readable, ...args) => new Promi
.catch(rej);
}
rej(new Error('un-compatible file.'));
- }).then(([path, remove]): Promise<any> => new Promise((res, rej) => {
- addFile(user, path, ...args)
- .then(file => {
- res(file);
- if (remove) {
- fs.unlink(path, (e) => {
- if (e) log(e.stack);
- });
- }
- })
- .catch(rej);
- }))
+ })
+ .then(([path, remove]): Promise<any> => new Promise((res, rej) => {
+ addFile(user, path, ...args)
+ .then(file => {
+ res(file);
+ if (remove) {
+ fs.unlink(path, (e) => {
+ if (e) log(e.stack);
+ });
+ }
+ })
+ .catch(rej);
+ }))
.then(file => {
log(`drive file has been created ${file._id}`);
resolve(file);
diff --git a/src/api/server.ts b/src/api/server.ts
index 3de32d9eab..026357b465 100644
--- a/src/api/server.ts
+++ b/src/api/server.ts
@@ -40,7 +40,7 @@ app.get('/', (req, res) => {
endpoints.forEach(endpoint =>
endpoint.withFile ?
app.post(`/${endpoint.name}`,
- endpoint.withFile ? multer({ dest: 'uploads/' }).single('file') : null,
+ endpoint.withFile ? multer({ storage: multer.diskStorage({}) }).single('file') : null,
require('./api-handler').default.bind(null, endpoint)) :
app.post(`/${endpoint.name}`,
require('./api-handler').default.bind(null, endpoint))