@@ -388,5 +388,51 @@ void main() {
388388
389389 await storage.from (newBucketName).copy (uploadPath, "$uploadPath 2" );
390390 });
391+
392+ test ('copy to different bucket' , () async {
393+ final storage = SupabaseStorageClient (
394+ storageUrl, {'Authorization' : 'Bearer $storageKey ' });
395+
396+ try {
397+ await storage.from ('bucket2' ).download (uploadPath);
398+ fail ('File that does not exist was found' );
399+ } on StorageException catch (error) {
400+ expect (error.error, 'not_found' );
401+ }
402+ await storage
403+ .from (newBucketName)
404+ .copy (uploadPath, uploadPath, destinationBucket: 'bucket2' );
405+ try {
406+ await storage.from ('bucket2' ).download (uploadPath);
407+ } catch (error) {
408+ fail ('File that was copied was not found' );
409+ }
410+ });
411+
412+ test ('move to different bucket' , () async {
413+ final storage = SupabaseStorageClient (
414+ storageUrl, {'Authorization' : 'Bearer $storageKey ' });
415+
416+ try {
417+ await storage.from ('bucket2' ).download ('$uploadPath 3' );
418+ fail ('File that does not exist was found' );
419+ } on StorageException catch (error) {
420+ expect (error.error, 'not_found' );
421+ }
422+ await storage
423+ .from (newBucketName)
424+ .move (uploadPath, '$uploadPath 3' , destinationBucket: 'bucket2' );
425+ try {
426+ await storage.from ('bucket2' ).download ('$uploadPath 3' );
427+ } catch (error) {
428+ fail ('File that was moved was not found' );
429+ }
430+ try {
431+ await storage.from (newBucketName).download (uploadPath);
432+ fail ('File that was moved was found' );
433+ } on StorageException catch (error) {
434+ expect (error.error, 'not_found' );
435+ }
436+ });
391437 });
392438}
0 commit comments