2018-11-01 19:32:24 +01:00
|
|
|
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
2018-07-16 21:36:44 +02:00
|
|
|
const ms = require('ms');
|
2018-03-29 13:32:18 +02:00
|
|
|
import { pack } from '../../../../../models/drive-file';
|
2018-04-07 21:02:12 +02:00
|
|
|
import uploadFromUrl from '../../../../../services/drive/upload-from-url';
|
2018-11-02 05:47:44 +01:00
|
|
|
import define from '../../../define';
|
2017-02-16 21:46:14 +01:00
|
|
|
|
2018-07-16 21:36:44 +02:00
|
|
|
export const meta = {
|
|
|
|
desc: {
|
2018-08-28 23:59:43 +02:00
|
|
|
'ja-JP': 'ドライブに指定されたURLに存在するファイルをアップロードします。'
|
2018-07-16 21:36:44 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
limit: {
|
|
|
|
duration: ms('1hour'),
|
|
|
|
max: 10
|
|
|
|
},
|
|
|
|
|
|
|
|
requireCredential: true,
|
|
|
|
|
2018-11-01 19:32:24 +01:00
|
|
|
kind: 'drive-write',
|
|
|
|
|
|
|
|
params: {
|
|
|
|
url: {
|
|
|
|
// TODO: Validate this url
|
|
|
|
validator: $.str,
|
|
|
|
},
|
|
|
|
|
|
|
|
folderId: {
|
|
|
|
validator: $.type(ID).optional.nullable,
|
|
|
|
default: null as any as any,
|
|
|
|
transform: transform
|
|
|
|
},
|
|
|
|
}
|
2018-07-16 21:36:44 +02:00
|
|
|
};
|
|
|
|
|
2018-11-02 05:47:44 +01:00
|
|
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
|
|
|
res(pack(await uploadFromUrl(ps.url, user, ps.folderId)));
|
|
|
|
}));
|