File tree Expand file tree Collapse file tree 4 files changed +31
-6
lines changed Expand file tree Collapse file tree 4 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
Generated by [ ` auto-changelog ` ] ( https://github.com/CookPete/auto-changelog ) .
9
9
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
+
10
26
## [ v2.10.6] ( https://github.com/tencentyun/cos-nodejs-sdk-v5/compare/v2.10.5...v2.10.6 ) - 2021-10-22
11
27
12
28
fix:修复COS.Util类型
Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ declare namespace COS {
68
68
type Initiator = Owner ;
69
69
/** 单个授权信息 */
70
70
type Grant = string ;
71
+ /** RFC 2616 中定义的字节范围。 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35 */
72
+ type Range = string ;
71
73
/** 被授权者信息与权限信息 */
72
74
interface Grants {
73
75
/** 所有者的信息 */
@@ -1150,6 +1152,8 @@ declare namespace COS {
1150
1152
/** getObject 接口参数 */
1151
1153
interface GetObjectParams extends ObjectParams {
1152
1154
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 ;
1153
1157
/** 写入流,可以传本地文件写入流 */
1154
1158
Output ?: Stream ,
1155
1159
/** 请求里的 Url Query 参数,传入该值中的 key/value 将会被 URLEncode */
Original file line number Diff line number Diff line change @@ -795,6 +795,9 @@ function uploadFile(params, callback) {
795
795
var taskList = [ ] ;
796
796
797
797
fs . stat ( params . FilePath , function ( err , stat ) {
798
+ if ( err ) {
799
+ return callback ( err ) ;
800
+ }
798
801
799
802
var isDir = stat . isDirectory ( ) ;
800
803
var FileSize = params . ContentLength = stat . size || 0 ;
@@ -871,9 +874,8 @@ function uploadFiles(params, callback) {
871
874
var count = params . files . length ;
872
875
util . each ( params . files , function ( fileParams , index ) {
873
876
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 ;
877
879
var fileInfo = { Index : index , TaskId : '' } ;
878
880
879
881
// 更新文件总大小
Original file line number Diff line number Diff line change @@ -176,9 +176,12 @@ var md5 = function (str, encoding) {
176
176
// 获取文件分片
177
177
var fileSlice = function ( FilePath , start , end , callback ) {
178
178
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
+ }
182
185
} else {
183
186
callback ( null ) ;
184
187
}
You can’t perform that action at this time.
0 commit comments