This commit is contained in:
syuilo 2017-03-05 12:00:39 +09:00
parent f210260826
commit 17a23c3eb5
67 changed files with 202 additions and 801 deletions

View file

@ -3,7 +3,7 @@
*/
import * as URL from 'url';
const download = require('download');
import it from '../../../it';
import it from 'cafy';
import { validateFileName } from '../../../models/drive-file';
import serialize from '../../../serializers/drive-file';
import create from '../../../common/add-file-to-drive';
@ -18,7 +18,7 @@ import create from '../../../common/add-file-to-drive';
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'url' parameter
// TODO: Validate this url
const [url, urlErr] = it(params.url).expect.string().required().qed();
const [url, urlErr] = it(params.url).expect.string().required().get();
if (urlErr) return rej('invalid url param');
let name = URL.parse(url).pathname.split('/').pop();
@ -27,7 +27,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Get 'folder_id' parameter
const [folderId, folderIdErr] = it(params.folder_id).expect.nullable.id().default(null).qed();
const [folderId = null, folderIdErr] = it(params.folder_id).expect.nullable.id().get();
if (folderIdErr) return rej('invalid folder_id param');
// Download file