doomistorage 1.0.5 → 1.0.6
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/dist/cosfile.js +1 -0
- package/dist/filehelper.d.ts +1 -1
- package/dist/filehelper.js +15 -6
- package/package.json +1 -1
- package/src/cosfile.ts +1 -0
- package/src/filehelper.ts +13 -7
package/dist/cosfile.js
CHANGED
|
@@ -61,6 +61,7 @@ class CosFile extends file_1.FileBase {
|
|
|
61
61
|
saveFileStream(file, fileName, saveOption, userInfo) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
const destinationFileName = this.getSaveFileName(saveOption, fileName, userInfo);
|
|
64
|
+
console.log('InStorage saveFileStream', saveOption);
|
|
64
65
|
return new Promise((resolve) => {
|
|
65
66
|
if (saveOption.reRead) {
|
|
66
67
|
let dataArr = [], //存储读取的结果集合
|
package/dist/filehelper.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type FileProviderEnum = typeof FileProviderEnum[keyof typeof FileProvider
|
|
|
13
13
|
* @param destination
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
export declare function FileHelper(provider
|
|
16
|
+
export declare function FileHelper(provider?: FileProviderEnum, apiOption?: any): FileUtility;
|
|
17
17
|
/**
|
|
18
18
|
* 文件帮助工具
|
|
19
19
|
*/
|
package/dist/filehelper.js
CHANGED
|
@@ -18,17 +18,24 @@ const localfile_1 = require("./localfile");
|
|
|
18
18
|
const axios_1 = __importDefault(require("axios"));
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
20
|
const fs_1 = __importDefault(require("fs"));
|
|
21
|
+
let config;
|
|
21
22
|
/**
|
|
22
23
|
* 读取系统配置文件的腾讯云设置
|
|
23
24
|
* @returns
|
|
24
25
|
*/
|
|
25
|
-
function getConfigurationSetting(settingName) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
function getConfigurationSetting(settingName, isSection = true) {
|
|
27
|
+
var _a;
|
|
28
|
+
if (!config) {
|
|
29
|
+
let configfilename = process.env["CONFIGFILE"] || 'configuration.json';
|
|
30
|
+
let configfile = path_1.default.join(process.cwd(), configfilename);
|
|
31
|
+
if (!fs_1.default.existsSync(configfile))
|
|
32
|
+
return null;
|
|
33
|
+
config = require(configfile);
|
|
34
|
+
}
|
|
35
|
+
if (!config)
|
|
29
36
|
return null;
|
|
30
|
-
const config = require(configfile)[settingName || 'tencentCOS'];
|
|
31
|
-
return config;
|
|
37
|
+
//const config = require(configfile)[settingName || 'tencentCOS'];
|
|
38
|
+
return isSection ? config[settingName || 'tencentCOS'] : ((_a = config.appsetting[settingName || 'destination']) !== null && _a !== void 0 ? _a : 'tencentcos');
|
|
32
39
|
}
|
|
33
40
|
/**
|
|
34
41
|
* 文件处理器类型
|
|
@@ -43,6 +50,8 @@ exports.FileProviderEnum = {
|
|
|
43
50
|
* @returns
|
|
44
51
|
*/
|
|
45
52
|
function FileHelper(provider, apiOption) {
|
|
53
|
+
if (!provider)
|
|
54
|
+
provider = getConfigurationSetting('destination', false);
|
|
46
55
|
let filehandler;
|
|
47
56
|
switch (provider) {
|
|
48
57
|
case exports.FileProviderEnum.LOCAL:
|
package/package.json
CHANGED
package/src/cosfile.ts
CHANGED
|
@@ -49,6 +49,7 @@ export class CosFile extends FileBase {
|
|
|
49
49
|
*/
|
|
50
50
|
async saveFileStream(file: any, fileName: any, saveOption: FileConfig, userInfo: any): Promise<FileResult> {
|
|
51
51
|
const destinationFileName = this.getSaveFileName(saveOption, fileName, userInfo);
|
|
52
|
+
console.log('InStorage saveFileStream', saveOption)
|
|
52
53
|
return new Promise((resolve) => {
|
|
53
54
|
if (saveOption.reRead) {
|
|
54
55
|
let dataArr: any = [],//存储读取的结果集合
|
package/src/filehelper.ts
CHANGED
|
@@ -5,16 +5,21 @@ import { LocalFile } from "./localfile";
|
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import fs from 'fs';
|
|
8
|
+
let config:any;
|
|
8
9
|
/**
|
|
9
10
|
* 读取系统配置文件的腾讯云设置
|
|
10
11
|
* @returns
|
|
11
12
|
*/
|
|
12
|
-
function getConfigurationSetting(settingName?:string):any{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
function getConfigurationSetting(settingName?:string,isSection:boolean=true):any{
|
|
14
|
+
if (!config){
|
|
15
|
+
let configfilename = process.env["CONFIGFILE"] || 'configuration.json'
|
|
16
|
+
let configfile = path.join(process.cwd(), configfilename);
|
|
17
|
+
if (!fs.existsSync(configfile)) return null;
|
|
18
|
+
config = require(configfile);
|
|
19
|
+
}
|
|
20
|
+
if (!config) return null;
|
|
21
|
+
//const config = require(configfile)[settingName || 'tencentCOS'];
|
|
22
|
+
return isSection ? config[settingName || 'tencentCOS'] : (config.appsetting[settingName ||'destination']??'tencentcos') ;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* 文件处理器类型
|
|
@@ -29,7 +34,8 @@ export type FileProviderEnum = typeof FileProviderEnum[keyof typeof FileProvider
|
|
|
29
34
|
* @param destination
|
|
30
35
|
* @returns
|
|
31
36
|
*/
|
|
32
|
-
export function FileHelper(provider
|
|
37
|
+
export function FileHelper(provider?: FileProviderEnum, apiOption?: any): FileUtility {
|
|
38
|
+
if (!provider) provider = getConfigurationSetting('destination',false)
|
|
33
39
|
let filehandler: FileBase
|
|
34
40
|
switch (provider) {
|
|
35
41
|
case FileProviderEnum.LOCAL: filehandler = new LocalFile(); break;
|