@xuda.io/drive_module 1.1.786 → 1.1.787
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/index.js +101 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -404,14 +404,112 @@ exports.get_drive_files = async function (req) {
|
|
|
404
404
|
return err.message;
|
|
405
405
|
}
|
|
406
406
|
};
|
|
407
|
+
// exports.get_drive_file_info = async function (req) {
|
|
408
|
+
// try {
|
|
409
|
+
// const { type, drive_type, app_id, file_name } = req;
|
|
410
|
+
// var { file_path } = req;
|
|
411
|
+
|
|
412
|
+
// let doc_ret,
|
|
413
|
+
// doc_id,
|
|
414
|
+
// doc = {};
|
|
415
|
+
|
|
416
|
+
// const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
417
|
+
|
|
418
|
+
// switch (drive_type) {
|
|
419
|
+
// case "studio": {
|
|
420
|
+
// const target_dir = path.join(_conf[`studio_drive_path`], app_id_master);
|
|
421
|
+
// doc_id = file_path.replace(target_dir, "");
|
|
422
|
+
// doc_ret = await db_module.get_app_couch_doc(app_id_master, doc_id);
|
|
423
|
+
// break;
|
|
424
|
+
// }
|
|
425
|
+
|
|
426
|
+
// case "workspace": {
|
|
427
|
+
// if (
|
|
428
|
+
// type === "file" &&
|
|
429
|
+
// !file_path.includes(app_id) &&
|
|
430
|
+
// !file_path.includes(app_id_master)
|
|
431
|
+
// ) {
|
|
432
|
+
// throw new Error("file_path unauthorized");
|
|
433
|
+
// }
|
|
434
|
+
// const app_id_reference = await _common.get_project_app_id(app_id);
|
|
435
|
+
// doc_id = path.basename(file_path);
|
|
436
|
+
// doc_ret = await db_module.get_app_couch_doc(app_id_reference, doc_id);
|
|
437
|
+
// break;
|
|
438
|
+
// }
|
|
439
|
+
|
|
440
|
+
// case "user": {
|
|
441
|
+
// doc_id = path.basename(file_path);
|
|
442
|
+
// doc_ret = await db_module.get_couch_doc("xuda_drive", doc_id);
|
|
443
|
+
// break;
|
|
444
|
+
// }
|
|
445
|
+
// default:
|
|
446
|
+
// break;
|
|
447
|
+
// }
|
|
448
|
+
|
|
449
|
+
// var statsObj = {};
|
|
450
|
+
// if (doc_ret.code > -1) {
|
|
451
|
+
// doc = doc_ret.data;
|
|
452
|
+
|
|
453
|
+
// delete doc._id;
|
|
454
|
+
// delete doc._rev;
|
|
455
|
+
|
|
456
|
+
// delete doc.docType;
|
|
457
|
+
// delete doc.stat;
|
|
458
|
+
// if (doc.bucket) {
|
|
459
|
+
// doc.regions = Object.entries(doc.bucket).length;
|
|
460
|
+
// }
|
|
461
|
+
|
|
462
|
+
// delete doc.bucket;
|
|
463
|
+
// if (doc.uid) {
|
|
464
|
+
// let ret = await db_module.get_couch_doc("xuda_accounts", doc.uid);
|
|
465
|
+
// doc.account_info = ret.data.account_info;
|
|
466
|
+
// }
|
|
467
|
+
// if (req.drive_type === "workspace") {
|
|
468
|
+
// const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
469
|
+
// const ret = await db_module.get_app_obj(app_id_master);
|
|
470
|
+
|
|
471
|
+
// if (ret.code < 0) {
|
|
472
|
+
// return ret;
|
|
473
|
+
// }
|
|
474
|
+
// const app_obj = ret.data;
|
|
475
|
+
// doc.app_name = app_obj.app_name;
|
|
476
|
+
// }
|
|
477
|
+
// } else if (drive_type === "studio") {
|
|
478
|
+
// statsObj = fs.statSync(file_path);
|
|
479
|
+
// }
|
|
480
|
+
|
|
481
|
+
// return {
|
|
482
|
+
// code: 200,
|
|
483
|
+
// data: {
|
|
484
|
+
// name: doc_ret.code < 0 ? file_name : doc.originalname,
|
|
485
|
+
// cy_data:
|
|
486
|
+
// doc_ret.code < 0
|
|
487
|
+
// ? { date_created: new Date(statsObj.birthtime).valueOf() }
|
|
488
|
+
// : doc,
|
|
489
|
+
// exif_data: doc.exif_data,
|
|
490
|
+
// },
|
|
491
|
+
// };
|
|
492
|
+
// } catch (err) {
|
|
493
|
+
// return {
|
|
494
|
+
// code: -200,
|
|
495
|
+
// data: err.message,
|
|
496
|
+
// };
|
|
497
|
+
// }
|
|
498
|
+
// };
|
|
499
|
+
|
|
407
500
|
exports.get_drive_file_info = async function (req) {
|
|
408
501
|
try {
|
|
409
502
|
const { type, drive_type, app_id, file_name } = req;
|
|
410
503
|
var { file_path } = req;
|
|
411
504
|
|
|
505
|
+
let doc=await get_drive_doc(drive_type, app_id,
|
|
506
|
+
uid,
|
|
507
|
+
file_path,
|
|
508
|
+
headers)
|
|
509
|
+
|
|
412
510
|
let doc_ret,
|
|
413
511
|
doc_id,
|
|
414
|
-
|
|
512
|
+
|
|
415
513
|
|
|
416
514
|
const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
417
515
|
|
|
@@ -2592,6 +2690,7 @@ const get_drive_doc = async function (
|
|
|
2592
2690
|
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
2593
2691
|
const file_name = path.basename(file_path);
|
|
2594
2692
|
const ext = path.extname(file_name).toLowerCase();
|
|
2693
|
+
const statsObj = fs.statSync(file_path);
|
|
2595
2694
|
doc = {
|
|
2596
2695
|
_id: file_path,
|
|
2597
2696
|
docType: `studio_drive`,
|
|
@@ -2599,7 +2698,7 @@ const get_drive_doc = async function (
|
|
|
2599
2698
|
server_file_name: file_name,
|
|
2600
2699
|
originalname: file_name,
|
|
2601
2700
|
file_path: file_path,
|
|
2602
|
-
date_created: Date.
|
|
2701
|
+
date_created: new Date(statsObj.birthtime).valueOf(),
|
|
2603
2702
|
ip: headers?.["cf-connecting-ip"],
|
|
2604
2703
|
country: headers?.["cf-ipcountry"],
|
|
2605
2704
|
file_ext: ext,
|