@@ -17,6 +17,7 @@ var cos = new COS({
1717 ChunkSize : 1024 * 1024 * 8 , // 控制分片大小,单位 B,在同园区上传可以设置较大的分片大小
1818 Proxy : '' ,
1919 Protocol : 'https:' ,
20+ FollowRedirect : false ,
2021} ) ;
2122
2223var TaskId ;
@@ -830,6 +831,14 @@ function putObjectCopy() {
830831 } ) ;
831832}
832833
834+ cos . deleteObject ( {
835+ Bucket : config . Bucket ,
836+ Region : config . Region ,
837+ Key : 'pingjs/ext2020/qqindex2018/dist/img/qq_logo_2x.png' ,
838+ } , function ( err , data ) {
839+ getObject ( ) ;
840+ } ) ;
841+
833842function getObject ( ) {
834843 var filepath1 = path . resolve ( __dirname , '1mb.out1.zip' ) ;
835844 var filepath2 = path . resolve ( __dirname , '1mb.out2.zip' ) ;
@@ -839,39 +848,16 @@ function getObject() {
839848 cos . getObject ( {
840849 Bucket : config . Bucket ,
841850 Region : config . Region ,
842- Key : '1mb.zip ' ,
851+ Key : 'pingjs/ext2020/qqindex2018/dist/img/qq_logo_2x.png ' ,
843852 onProgress : function ( progressData ) {
844853 console . log ( JSON . stringify ( progressData ) ) ;
845854 }
846855 } , function ( err , data ) {
847- fs . writeFileSync ( filepath1 , data . Body ) ;
856+ console . log ( err ) ;
857+ console . log ( data ) ;
858+ // fs.writeFileSync(filepath1, data.Body);
848859 } ) ;
849860
850- // file2 获取对象到本地文件
851- cos . getObject ( {
852- Bucket : config . Bucket ,
853- Region : config . Region ,
854- Key : '1mb.zip' ,
855- Output : fs . createWriteStream ( filepath2 ) ,
856- onProgress : function ( progressData ) {
857- console . log ( JSON . stringify ( progressData ) ) ;
858- }
859- } , function ( err , data ) {
860- console . log ( err || data ) ;
861- } ) ;
862-
863- // file3 pipe 格式获取对象到本地文件
864- var stream = cos . getObjectStream ( {
865- Bucket : config . Bucket ,
866- Region : config . Region ,
867- Key : '1mb.zip' ,
868- onProgress : function ( progressData ) {
869- console . log ( JSON . stringify ( progressData ) ) ;
870- }
871- } , function ( err , data ) {
872- console . log ( err || data ) ;
873- } ) ;
874- stream . pipe ( fs . createWriteStream ( filepath3 ) )
875861}
876862
877863function headObject ( ) {
0 commit comments