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 {
3232 if ( e . error . Code == 'BucketAlreadyExists' || e . error . Code == 'BucketAlreadyOwnedByYou' ) {
3333 if ( ! inputs . force ) {
3434 throw new Error ( JSON . stringify ( e ) ) ;
35+ } else {
36+ console . log ( `Bucket ${ inputs . bucket } already exist.` ) ;
3537 }
3638 } else {
3739 // cos在云函数中可能出现ECONNRESET错误,没办法具体定位,初步猜测是客户端问题,是函数启动网络还没准备好,这个还不确定,所以在这里做兼容
@@ -43,6 +45,8 @@ class Cos {
4345 if ( isHave . statusCode == 200 ) {
4446 if ( ! inputs . force ) {
4547 throw new Error ( 'BucketAlreadyExists and BucketAlreadyOwnedByYou' ) ;
48+ } else {
49+ console . log ( `Bucket ${ inputs . bucket } already exist.` ) ;
4650 }
4751 } else {
4852 throw new Error ( 'Could not find this bucket' ) ;
@@ -501,6 +505,19 @@ class Cos {
501505 if ( inputs . versioning ) {
502506 await this . setVersioning ( inputs ) ;
503507 }
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+ }
504521 return inputs ;
505522 }
506523
You can’t perform that action at this time.
0 commit comments