shareFiles method

Future<Map<String, FileTransferObject>> shareFiles(
  1. List<String> sharedWithAtSigns,
  2. String key,
  3. String fileUrl,
  4. String encryptionKey,
  5. List<FileStatus> fileStatus, {
  6. DateTime? date,
})

Implementation

Future<Map<String, FileTransferObject>> shareFiles(
    List<String> sharedWithAtSigns,
    String key,
    String fileUrl,
    String encryptionKey,
    List<FileStatus> fileStatus,
    {DateTime? date}) async {
  var result = <String, FileTransferObject>{};
  for (var sharedWithAtSign in sharedWithAtSigns) {
    var fileTransferObject = FileTransferObject(
        key, encryptionKey, fileUrl, sharedWithAtSign, fileStatus,
        date: date);
    try {
      var atKey = AtKey()
        ..key = key
        ..sharedWith = sharedWithAtSign
        ..metadata = Metadata()
        ..metadata!.ttr = -1
        ..sharedBy = currentAtSign;
      fileTransferObject.sharedStatus =
          await put(atKey, jsonEncode(fileTransferObject.toJson()));
    } on Exception catch (e) {
      fileTransferObject.sharedStatus = false;
      fileTransferObject.error = e.toString();
    }
    result[sharedWithAtSign] = fileTransferObject;
  }
  return result;
}