copy method

Future<String> copy(
  1. String fromPath,
  2. String toPath
)

Copies an existing file.

fromPath is the original file path, including the current file name. For example folder/image.png.

toPath is the new file path, including the new file name. For example folder/image-copy.png.

Implementation

Future<String> copy(String fromPath, String toPath) async {
  final options = FetchOptions(headers: headers);
  final response = await _storageFetch.post(
    '$url/object/copy',
    {
      'bucketId': bucketId,
      'sourceKey': fromPath,
      'destinationKey': toPath,
    },
    options: options,
  );
  return (response as Map<String, dynamic>)['Key'] as String;
}