dfs-adapter 0.0.1 → 0.0.3

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/lib/mdfs.js CHANGED
@@ -35,11 +35,9 @@ class MDFSHttpListenerWrapper {
35
35
  };
36
36
  }
37
37
  get(filename, res) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- let { name, ext } = require('path').parse(filename);
40
- res.attachment(`${name}${ext}`);
41
- return this.dfs.download(filename);
42
- });
38
+ let { name, ext } = require('path').parse(filename);
39
+ res.attachment(`${name}${ext}`);
40
+ return this.dfs.download(filename);
43
41
  }
44
42
  }
45
43
  class Mdfs extends declare_1.Dfs {
package/lib/minio.js CHANGED
@@ -54,7 +54,7 @@ class MinioDfs extends declare_1.Dfs {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
55
  try {
56
56
  this.timeBegin(`upload ${path}`);
57
- this.client.putObject(this.options.bucketName, path, buffer, ...args);
57
+ yield this.client.putObject(this.options.bucketName, path, buffer, ...args);
58
58
  return _super.upload.call(this, path, buffer, ...args);
59
59
  }
60
60
  finally {
package/lib/native.d.ts CHANGED
@@ -6,7 +6,7 @@ export default class NativeDfs extends Dfs<'native'> {
6
6
  type: 'native';
7
7
  }, context: VWebApplicationContext);
8
8
  startup(): Promise<void>;
9
- upload(path: string, buffer: any, ...args: any[]): Promise<string>;
10
- download(path: string, ...args: any[]): Promise<Buffer>;
9
+ upload(path: string, buffer: any): Promise<string>;
10
+ download(path: string): Promise<Buffer>;
11
11
  getAccess(path: string): Promise<string>;
12
12
  }
package/lib/native.js CHANGED
@@ -31,9 +31,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
34
37
  Object.defineProperty(exports, "__esModule", { value: true });
35
38
  const declare_1 = require("./declare");
39
+ const vweb_core_1 = require("vweb-core");
36
40
  const fs = __importStar(require("fs"));
41
+ const path_1 = __importDefault(require("path"));
37
42
  class NativeDfs extends declare_1.Dfs {
38
43
  constructor(options, context) {
39
44
  super(options, context);
@@ -43,32 +48,36 @@ class NativeDfs extends declare_1.Dfs {
43
48
  startup: { get: () => super.startup }
44
49
  });
45
50
  return __awaiter(this, void 0, void 0, function* () {
51
+ vweb_core_1.util.file.forceMkDirSync(this.options.storage);
46
52
  return _super.startup.call(this);
47
53
  });
48
54
  }
49
- upload(path, buffer, ...args) {
55
+ upload(path, buffer) {
50
56
  const _super = Object.create(null, {
51
57
  upload: { get: () => super.upload }
52
58
  });
53
59
  return __awaiter(this, void 0, void 0, function* () {
54
60
  try {
55
61
  this.timeBegin(`upload ${path}`);
56
- fs.writeFileSync(`${this.options.storage}${path}`, buffer);
57
- return _super.upload.call(this, path, buffer, ...args);
62
+ let file = `${this.options.storage}${path}`;
63
+ let { dir } = path_1.default.parse(file);
64
+ vweb_core_1.util.file.forceMkDirSync(dir);
65
+ fs.writeFileSync(file, buffer);
66
+ return _super.upload.call(this, path, buffer);
58
67
  }
59
68
  finally {
60
69
  this.timeEnd(`upload ${path}`);
61
70
  }
62
71
  });
63
72
  }
64
- download(path, ...args) {
73
+ download(path) {
65
74
  const _super = Object.create(null, {
66
75
  download: { get: () => super.download }
67
76
  });
68
77
  return __awaiter(this, void 0, void 0, function* () {
69
78
  try {
70
79
  this.timeBegin(`download ${path}`);
71
- yield _super.download.call(this, path, ...args);
80
+ yield _super.download.call(this, path);
72
81
  return fs.readFileSync(`${this.options.storage}${path}`);
73
82
  }
74
83
  finally {
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "dfs-adapter",
3
- "version": "0.0.1",
4
- "description": "oss minio dfs native",
5
- "main": "./lib/index",
6
- "files": [
7
- "lib/"
8
- ],
9
- "scripts": {
10
- "test": "node bin/app.js",
11
- "build": "tsc --build tsconfig.json",
12
- "run": "npm run build && node bin/app.js"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git@codeup.aliyun.com:60b0836844816b8ed2335ed6/vweb/modules/mq-adapter.git"
17
- },
18
- "devDependencies": {
19
- "@babel/cli": "^7.16.0",
20
- "@babel/core": "^7.16.0",
21
- "@babel/plugin-proposal-decorators": "^7.16.4",
22
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
23
- "@babel/plugin-transform-runtime": "^7.16.4",
24
- "@babel/preset-env": "^7.16.4",
25
- "@babel/register": "^7.16.0",
26
- "@babel/runtime": "^7.16.3",
27
- "@types/ali-oss": "^6.16.3",
28
- "@types/node": "^16.11.12",
29
- "ali-oss": "^6.18.1",
30
- "axios": "^1.6.1",
31
- "babel-plugin-transform-decorators-legacy": "^1.3.5",
32
- "form-data": "^4.0.0",
33
- "minio": "^7.1.3",
34
- "vweb-core": "^3.0.14",
35
- "vweb-mvc": "^1.2.18"
36
- },
37
- "author": "",
38
- "license": "ISC"
39
- }
1
+ {
2
+ "name": "dfs-adapter",
3
+ "version": "0.0.3",
4
+ "description": "oss minio dfs native",
5
+ "main": "./lib/index",
6
+ "files": [
7
+ "lib/"
8
+ ],
9
+ "scripts": {
10
+ "test": "node bin/app.js",
11
+ "build": "tsc --build tsconfig.json",
12
+ "run": "npm run build && node bin/app.js"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git@codeup.aliyun.com:60b0836844816b8ed2335ed6/vweb/modules/mq-adapter.git"
17
+ },
18
+ "devDependencies": {
19
+ "@babel/cli": "^7.16.0",
20
+ "@babel/core": "^7.16.0",
21
+ "@babel/plugin-proposal-decorators": "^7.16.4",
22
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
23
+ "@babel/plugin-transform-runtime": "^7.16.4",
24
+ "@babel/preset-env": "^7.16.4",
25
+ "@babel/register": "^7.16.0",
26
+ "@babel/runtime": "^7.16.3",
27
+ "@types/ali-oss": "^6.16.3",
28
+ "@types/node": "^16.11.12",
29
+ "ali-oss": "^6.18.1",
30
+ "axios": "^1.6.1",
31
+ "babel-plugin-transform-decorators-legacy": "^1.3.5",
32
+ "form-data": "^4.0.0",
33
+ "minio": "^7.1.3",
34
+ "vweb-core": "^3.0.14",
35
+ "vweb-mvc": "^1.2.18"
36
+ },
37
+ "author": "",
38
+ "license": "ISC"
39
+ }