copy method

Future<AwsStorageResult<String>?> copy({
  1. String? from,
  2. required String to,
  3. required AwsStorageType type,
  4. List<int>? bytes,
  5. String? string,
})

Copies from one location to another the following data: file, directory, bytes, string.

Implementation

Future<AwsStorageResult<String>?> copy(
    {String? from,
    required String to,
    required AwsStorageType type,
    List<int>? bytes,
    String? string}) async {
  switch (type) {
    case AwsStorageType.directory:
      if (from != null) {
        if (to.isNotEmpty) {
          return AwsStorageResult((await _copyPathDirectory(from, to)).path);
        }
      }
      break;
    case AwsStorageType.file:
      if (from != null) {
        if (to.isNotEmpty) {
          return AwsStorageResult<String>(
              (await _copyPathFile(from, to)).path);
        }
      }

      break;
    case AwsStorageType.bytes:
      if (bytes != null) {
        return AwsStorageResult<String>(
            (await _copyPathBytes(bytes, to)).path);
      }
      break;
    case AwsStorageType.string:
      if (string != null) {
        return AwsStorageResult<String>((await _copyString(string, to)).path);
      }
      break;
  }
  return null;
}