saveMediaFromPath method

Future<String> saveMediaFromPath({
  1. required String messageId,
  2. required String sourcePath,
  3. required String fileName,
})

Saves a media file from a source path (move/copy).

Used when the user picks a file from their device — copies it into the Airpass media directory so it persists independently of the user's original file.

Returns the absolute path where the file was saved.

Implementation

Future<String> saveMediaFromPath({
  required String messageId,
  required String sourcePath,
  required String fileName,
}) async {
  final dir = await _getMessageMediaDir(messageId);
  final destPath = p.join(dir, fileName);
  final sourceFile = File(sourcePath);
  await sourceFile.copy(destPath);

  _log('Copied media: $sourcePath → $destPath');
  return destPath;
}