Skip to content

Commit b10644c

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat/ci-demo
2 parents 07c2c24 + c4a64fa commit b10644c

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
99

10+
## [v2.10.7](https://github.com/tencentyun/cos-nodejs-sdk-v5/compare/v2.10.6...v2.10.7) - 2021-11-09
11+
12+
fix:高级上传增加容错处理
13+
14+
### Merged
15+
16+
- fix:uploadFIle容错处理 [`#114`](https://github.com/tencentyun/cos-nodejs-sdk-v5/pull/114)
17+
- Fix:修复类型定义中getObject方法的options不包含Range选项的问题 [`#99`](https://github.com/tencentyun/cos-nodejs-sdk-v5/pull/99)
18+
19+
### Commits
20+
21+
- fix:优化uploadFile、uploadFIles文件路径不正确场景 [`96f810b`](https://github.com/tencentyun/cos-nodejs-sdk-v5/commit/96f810b47d73b37202ab118003356851eda17ef5)
22+
- Updated CHANGELOG.md [`02916b0`](https://github.com/tencentyun/cos-nodejs-sdk-v5/commit/02916b086bcd7406505bb0d67e0caecdbfb8e406)
23+
- fix:优化uploadFile、uploadFIles文件路径不正确场景 [`d8663a2`](https://github.com/tencentyun/cos-nodejs-sdk-v5/commit/d8663a20f6f99b28d306dd7f6718d54d1c907ecb)
24+
- bug fix:修复类型定义中getObject方法的options不包含Range选项的问题 [`37bda63`](https://github.com/tencentyun/cos-nodejs-sdk-v5/commit/37bda632c74f2e8a6bc044498a3a87d725268e2a)
25+
1026
## [v2.10.6](https://github.com/tencentyun/cos-nodejs-sdk-v5/compare/v2.10.5...v2.10.6) - 2021-10-22
1127

1228
fix:修复COS.Util类型

index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ declare namespace COS {
6868
type Initiator = Owner;
6969
/** 单个授权信息 */
7070
type Grant = string;
71+
/** RFC 2616 中定义的字节范围。 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35 */
72+
type Range = string;
7173
/** 被授权者信息与权限信息 */
7274
interface Grants {
7375
/** 所有者的信息 */
@@ -1150,6 +1152,8 @@ declare namespace COS {
11501152
/** getObject 接口参数 */
11511153
interface GetObjectParams extends ObjectParams {
11521154
BodyType?: 'text' | 'blob' | 'arraybuffer',
1155+
/** 下载对象的指定范围字节。参见 RFC 2616 中定义的字节范围,see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35。范围值必须使用 bytes=first-last 格式且仅支持单一范围,不支持多重范围。first 和 last 都是基于0开始的偏移量。例如 bytes=0-9 表示下载对象的开头10个字节的数据 ,如果不指定,则表示下载整个对象 */
1156+
Range?: Range;
11531157
/** 写入流,可以传本地文件写入流 */
11541158
Output?: Stream,
11551159
/** 请求里的 Url Query 参数,传入该值中的 key/value 将会被 URLEncode */

sdk/advance.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,9 @@ function uploadFile(params, callback) {
795795
var taskList = [];
796796

797797
fs.stat(params.FilePath, function (err, stat) {
798+
if (err) {
799+
return callback(err);
800+
}
798801

799802
var isDir = stat.isDirectory();
800803
var FileSize = params.ContentLength = stat.size || 0;
@@ -871,9 +874,8 @@ function uploadFiles(params, callback) {
871874
var count = params.files.length;
872875
util.each(params.files, function (fileParams, index) {
873876
fs.stat(fileParams.FilePath, function (err, stat) {
874-
875-
var isDir = stat.isDirectory();
876-
var FileSize = fileParams.ContentLength = stat.size || 0;
877+
var isDir = stat ? stat.isDirectory() : false;
878+
var FileSize = fileParams.ContentLength = stat ? stat.size : 0;
877879
var fileInfo = {Index: index, TaskId: ''};
878880

879881
// 更新文件总大小

sdk/util.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ var md5 = function (str, encoding) {
176176
// 获取文件分片
177177
var fileSlice = function (FilePath, start, end, callback) {
178178
if (FilePath) {
179-
var readStream = fs.createReadStream(FilePath, {start: start, end: end - 1});
180-
readStream.isSdkCreated = true;
181-
callback(readStream);
179+
try {
180+
var readStream = fs.createReadStream(FilePath, {start: start, end: end - 1});
181+
readStream.isSdkCreated = true;
182+
callback(readStream);
183+
} catch(e) {
184+
}
182185
} else {
183186
callback(null);
184187
}

0 commit comments

Comments
 (0)