@anytowork/cli 0.12.19 → 0.12.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli-parse.js +4 -0
- package/src/index.js +5 -3
package/package.json
CHANGED
package/src/cli-parse.js
CHANGED
|
@@ -193,6 +193,7 @@ export function parseArgs(argv) {
|
|
|
193
193
|
kind: null, // task request-upload --kind(attachment|deliverable)
|
|
194
194
|
mimeType: null, // task request-upload --mime-type
|
|
195
195
|
sizeBytes: null, // task request-upload --size-bytes(整数·字节数)
|
|
196
|
+
filename: null, // task request-upload / add-attachment --filename(文件原名,带后缀)
|
|
196
197
|
description: null, // capability create --description
|
|
197
198
|
type: null, // capability create --type
|
|
198
199
|
category: null, // capability create --category
|
|
@@ -353,6 +354,9 @@ export function parseArgs(argv) {
|
|
|
353
354
|
// M7:task request-upload 文件大小(字节·整数)
|
|
354
355
|
const v = args.shift();
|
|
355
356
|
flags.sizeBytes = v != null ? parseInt(v, 10) : null;
|
|
357
|
+
} else if (a === '--filename') {
|
|
358
|
+
// real file name incl. extension (Echo #380: required for task request-upload)
|
|
359
|
+
flags.filename = args.shift() ?? null;
|
|
356
360
|
} else if (a === '--description') {
|
|
357
361
|
flags.description = args.shift() ?? null;
|
|
358
362
|
} else if (a === '--type') {
|
package/src/index.js
CHANGED
|
@@ -242,7 +242,7 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
242
242
|
|
|
243
243
|
task download <file_id> [--json] 拿文件下载地址(返回 signed URL·自己 GET 下载)
|
|
244
244
|
|
|
245
|
-
task request-upload <task_id>
|
|
245
|
+
task request-upload <task_id> 申请上传文件(需 --filename 带后缀;返回 file_id + signed PUT URL·自己 PUT)
|
|
246
246
|
--kind <attachment|deliverable> 附件类型(需求材料 或 交付物)
|
|
247
247
|
--mime-type <类型> 文件 MIME(如 image/png · application/pdf)
|
|
248
248
|
--size-bytes <字节数> 文件大小
|
|
@@ -1397,13 +1397,15 @@ export async function run(argv, deps = {}) {
|
|
|
1397
1397
|
if (!flags.kind) { err('缺少 --kind 参数(attachment 或 deliverable)'); return 2; }
|
|
1398
1398
|
if (!flags.mimeType) { err('缺少 --mime-type 参数(如 image/png)'); return 2; }
|
|
1399
1399
|
if (flags.sizeBytes == null) { err('缺少 --size-bytes 参数(文件大小,单位字节)'); return 2; }
|
|
1400
|
+
// Echo #380: a file without its real name gets downloaded without an extension and cannot be opened.
|
|
1401
|
+
if (!flags.filename || !String(flags.filename).trim()) { err('缺少 --filename 参数(文件原名,带后缀,如 方案.pdf)'); return 2; }
|
|
1400
1402
|
const uploadData = {
|
|
1401
1403
|
task_id: taskId,
|
|
1402
1404
|
kind: flags.kind,
|
|
1403
1405
|
mime_type: flags.mimeType,
|
|
1404
1406
|
size_bytes: flags.sizeBytes,
|
|
1405
|
-
//
|
|
1406
|
-
|
|
1407
|
+
// real file name incl. extension (required since Echo #380)
|
|
1408
|
+
filename: String(flags.filename).trim(),
|
|
1407
1409
|
};
|
|
1408
1410
|
const data = await requestUpload(baseUrl, credOpts, uploadData, { fetchImpl });
|
|
1409
1411
|
log(formatRequestUpload(data, { json: flags.json }));
|