File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ class Cos {
32
32
if ( e . error . Code == 'BucketAlreadyExists' || e . error . Code == 'BucketAlreadyOwnedByYou' ) {
33
33
if ( ! inputs . force ) {
34
34
throw new Error ( JSON . stringify ( e ) ) ;
35
+ } else {
36
+ console . log ( `Bucket ${ inputs . bucket } already exist.` ) ;
35
37
}
36
38
} else {
37
39
// cos在云函数中可能出现ECONNRESET错误,没办法具体定位,初步猜测是客户端问题,是函数启动网络还没准备好,这个还不确定,所以在这里做兼容
@@ -43,6 +45,8 @@ class Cos {
43
45
if ( isHave . statusCode == 200 ) {
44
46
if ( ! inputs . force ) {
45
47
throw new Error ( 'BucketAlreadyExists and BucketAlreadyOwnedByYou' ) ;
48
+ } else {
49
+ console . log ( `Bucket ${ inputs . bucket } already exist.` ) ;
46
50
}
47
51
} else {
48
52
throw new Error ( 'Could not find this bucket' ) ;
@@ -501,6 +505,19 @@ class Cos {
501
505
if ( inputs . versioning ) {
502
506
await this . setVersioning ( inputs ) ;
503
507
}
508
+ if ( inputs . src ) {
509
+ // upload
510
+ const dirToUploadPath = inputs . src ;
511
+ const uploadDict = {
512
+ bucket : inputs . bucket ,
513
+ } ;
514
+ if ( fs . lstatSync ( dirToUploadPath ) . isDirectory ( ) ) {
515
+ uploadDict . dir = dirToUploadPath ;
516
+ } else {
517
+ uploadDict . file = dirToUploadPath ;
518
+ }
519
+ await this . upload ( uploadDict ) ;
520
+ }
504
521
return inputs ;
505
522
}
506
523
You can’t perform that action at this time.
0 commit comments