File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,34 @@ public async Task Copy()
169169 Assert . IsNotNull ( items . Find ( ( f ) => f . Name == "new-file.bin" ) ) ;
170170 Assert . IsNotNull ( items . Find ( ( f ) => f . Name == name ) ) ;
171171 }
172+
173+ [ TestMethod ( "File: Copy to another Bucket" ) ]
174+ public async Task CopyToAnotherBucket ( )
175+ {
176+ await Storage . CreateBucket ( "copyfile" , new BucketUpsertOptions { Public = true } ) ;
177+ var localBucket = Storage . From ( "copyfile" ) ;
178+
179+ var name = $ "{ Guid . NewGuid ( ) } .bin";
180+ await _bucket . Upload ( [ 0x0 , 0x1 ] , name ) ;
181+
182+ await _bucket . Copy ( name , "new-file.bin" , new DestinationOptions { DestinationBucket = "copyfile" } ) ;
183+ var items = await _bucket . List ( ) ;
184+ var copied = await localBucket . List ( ) ;
185+
186+ Assert . IsNotNull ( items ) ;
187+ Assert . IsNotNull ( copied ) ;
188+
189+ Assert . IsNotNull ( copied . Find ( ( f ) => f . Name == "new-file.bin" ) ) ;
190+ Assert . IsNotNull ( items . Find ( ( f ) => f . Name == name ) ) ;
191+
192+ foreach ( var file in copied )
193+ {
194+ if ( file . Name is not null )
195+ await localBucket . Remove ( new List < string > { file . Name } ) ;
196+ }
197+
198+ await Storage . DeleteBucket ( "copyfile" ) ;
199+ }
172200
173201 [ TestMethod ( "File: Get Public Link" ) ]
174202 public async Task GetPublicLink ( )
You can’t perform that action at this time.
0 commit comments