2019-02-04 19:48:08 -07:00
|
|
|
import $ from 'cafy';
|
|
|
|
import ID, { transform } from '../../../../../misc/cafy-id';
|
2019-02-01 08:16:27 -07:00
|
|
|
import * as ms from 'ms';
|
2018-03-29 05:32:18 -06:00
|
|
|
import { pack } from '../../../../../models/drive-file';
|
2018-04-07 13:02:12 -06:00
|
|
|
import uploadFromUrl from '../../../../../services/drive/upload-from-url';
|
2018-11-01 22:47:44 -06:00
|
|
|
import define from '../../../define';
|
2017-02-16 13:46:14 -07:00
|
|
|
|
2018-07-16 13:36:44 -06:00
|
|
|
export const meta = {
|
|
|
|
desc: {
|
2018-08-28 15:59:43 -06:00
|
|
|
'ja-JP': 'ドライブに指定されたURLに存在するファイルをアップロードします。'
|
2018-07-16 13:36:44 -06:00
|
|
|
},
|
|
|
|
|
2019-02-22 19:20:58 -07:00
|
|
|
tags: ['drive'],
|
|
|
|
|
2018-07-16 13:36:44 -06:00
|
|
|
limit: {
|
|
|
|
duration: ms('1hour'),
|
2018-11-06 20:12:43 -07:00
|
|
|
max: 60
|
2018-07-16 13:36:44 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
requireCredential: true,
|
|
|
|
|
2018-11-01 12:32:24 -06:00
|
|
|
kind: 'drive-write',
|
|
|
|
|
|
|
|
params: {
|
|
|
|
url: {
|
|
|
|
// TODO: Validate this url
|
|
|
|
validator: $.str,
|
|
|
|
},
|
|
|
|
|
|
|
|
folderId: {
|
2019-02-13 00:33:07 -07:00
|
|
|
validator: $.optional.nullable.type(ID),
|
2018-11-21 13:07:25 -07:00
|
|
|
default: null as any,
|
2018-11-01 12:32:24 -06:00
|
|
|
transform: transform
|
|
|
|
},
|
2018-11-06 20:12:43 -07:00
|
|
|
|
|
|
|
isSensitive: {
|
2019-02-13 00:33:07 -07:00
|
|
|
validator: $.optional.bool,
|
2018-11-06 20:12:43 -07:00
|
|
|
default: false,
|
|
|
|
desc: {
|
|
|
|
'ja-JP': 'このメディアが「閲覧注意」(NSFW)かどうか',
|
|
|
|
'en-US': 'Whether this media is NSFW'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
force: {
|
2019-02-13 00:33:07 -07:00
|
|
|
validator: $.optional.bool,
|
2018-11-06 20:12:43 -07:00
|
|
|
default: false,
|
|
|
|
desc: {
|
|
|
|
'ja-JP': 'true にすると、同じハッシュを持つファイルが既にアップロードされていても強制的にファイルを作成します。',
|
|
|
|
}
|
|
|
|
}
|
2018-11-01 12:32:24 -06:00
|
|
|
}
|
2018-07-16 13:36:44 -06:00
|
|
|
};
|
|
|
|
|
2019-02-21 19:46:58 -07:00
|
|
|
export default define(meta, async (ps, user) => {
|
|
|
|
return await pack(await uploadFromUrl(ps.url, user, ps.folderId, null, ps.isSensitive, ps.force), { self: true });
|
|
|
|
});
|