fsd-oss 0.9.0 → 0.10.1

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/README.md CHANGED
@@ -15,7 +15,7 @@ let content = await fsd.read();
15
15
 
16
16
  ```
17
17
 
18
- FSD 文档: https://github.com/maichong/fsd
18
+ FSD 文档: https://github.com/liangxingchen/fsd
19
19
 
20
20
  适配器初始化选项:
21
21
 
package/lib/index.js CHANGED
@@ -7,7 +7,6 @@ const minimatch = require("minimatch");
7
7
  const Debugger = require("debug");
8
8
  const eachLimit = require("async/eachLimit");
9
9
  const RPC = require("@alicloud/pop-core");
10
- const url_1 = require("url");
11
10
  const stream_1 = require("stream");
12
11
  const debug = Debugger('fsd-oss');
13
12
  const CALLBACK_BODY = 'bucket=${bucket}&path=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}&format=${imageInfo.format}';
@@ -274,8 +273,6 @@ class OSSAdapter {
274
273
  debug('copy %s to %s', path, dest);
275
274
  if (!(await this.exists(path)))
276
275
  throw new Error('The source path is not exists!');
277
- if (await this.exists(dest))
278
- throw new Error('The dest path is already exists!');
279
276
  const { root } = this._options;
280
277
  let from = slash(Path.join(root, path)).substr(1);
281
278
  let to = slash(Path.join(root, dest)).substr(1);
@@ -382,18 +379,17 @@ class OSSAdapter {
382
379
  let { uploadId } = res;
383
380
  let files = [];
384
381
  for (let i = 1; i <= partCount; i += 1) {
385
- files.push(`task://${uploadId}${path}?${i}`);
382
+ files.push(`task://${uploadId}?${i}`);
386
383
  }
387
384
  return files;
388
385
  }
389
386
  async writePart(path, partTask, data, size) {
390
387
  debug('writePart %s, task: %s', path, partTask);
391
- let p = slash(Path.join(this._options.root, path)).substr(1);
392
- let info = new url_1.URL(partTask);
393
- if (!info.pathname || info.pathname !== path)
394
- throw new Error('Invalid part pathname');
395
- let uploadId = (info.hostname || '').toUpperCase();
396
- let res = await this._oss._uploadPart(p, uploadId, info.search.substr(1), {
388
+ let p = slash(Path.join(this._options.root, path)).substring(1);
389
+ if (!partTask.startsWith('task://'))
390
+ throw new Error('Invalid part task id');
391
+ let [uploadId, no] = partTask.replace('task://', '').split('?');
392
+ let res = await this._oss._uploadPart(p, uploadId, parseInt(no), {
397
393
  stream: data,
398
394
  size
399
395
  });
@@ -402,11 +398,8 @@ class OSSAdapter {
402
398
  }
403
399
  async completeMultipartUpload(path, parts) {
404
400
  debug('completeMultipartUpload %s', path);
405
- let info = new url_1.URL(parts[0]);
406
- if (!info.pathname || info.pathname !== path)
407
- throw new Error('Invalid part pathname');
408
- let uploadId = (info.hostname || '').toUpperCase();
409
- let p = slash(Path.join(this._options.root, path)).substr(1);
401
+ let uploadId = parts[0].replace('part://', '').split('?')[0];
402
+ let p = slash(Path.join(this._options.root, path)).substring(1);
410
403
  debug('update id: %s, target: %s', uploadId, p);
411
404
  let datas = parts.map((item, key) => ({
412
405
  etag: item.split('#')[1],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fsd-oss",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "description": "Aliyun OSS adapter for fsd",
5
5
  "main": "lib/index.js",
6
6
  "types": "index.d.ts",
@@ -8,16 +8,16 @@
8
8
  "build": "tsc",
9
9
  "prepublish": "npm run build"
10
10
  },
11
- "repository": "https://github.com/maichong/fsd/tree/master/packages/fsd-oss",
12
- "author": "Liang <liang@maichong.it> (https://github.com/liangxingchen)",
11
+ "repository": "https://github.com/liangxingchen/fsd/tree/master/packages/fsd-oss",
12
+ "author": "Liang <liang@miaomo.cc> (https://github.com/liangxingchen)",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@alicloud/pop-core": "^1.7.10",
16
- "ali-oss": "^6.16.0",
15
+ "@alicloud/pop-core": "^1.7.12",
16
+ "ali-oss": "^6.17.1",
17
17
  "async": "*",
18
- "debug": "^4.3.2",
19
- "minimatch": "^3.0.4",
18
+ "debug": "^4.3.4",
19
+ "minimatch": "^3.1.2",
20
20
  "slash": "^3.0.0"
21
21
  },
22
- "gitHead": "1803b2521d07819f8ae55d8ba39c847512061772"
22
+ "gitHead": "0e15db87212337e709c07bdc9c855132bb347db9"
23
23
  }