AppFile.fromPlatformFile constructor

AppFile.fromPlatformFile(
  1. PlatformFile file, {
  2. String fileKey = '',
})

Implementation

factory AppFile.fromPlatformFile(PlatformFile file, {String fileKey = ''}) {
  final resolvedPath = _safePlatformFilePath(file);
  final resolvedName =
      file.name.isNotEmpty ? file.name : _nameFromPath(resolvedPath);
  final resolvedExtension = _resolveExtension(
    explicitExtension: file.extension,
    fileName: resolvedName,
    filePath: resolvedPath,
  );
  final resolvedBytes = file.bytes;

  return AppFile(
    fileKey: fileKey,
    fileName: resolvedName,
    filePath: resolvedPath,
    fileBytes: resolvedBytes,
    fileExtension: resolvedExtension,
    fileType: _resolveFileType(
      fileUrl: null,
      fileExtension: resolvedExtension,
    ),
    size: file.size,
    xFile: _buildXFile(
      name: resolvedName,
      path: resolvedPath,
      bytes: resolvedBytes,
      extension: resolvedExtension,
      size: file.size,
    ),
  );
}