Files
tatuchat/lib/pages/chat/utils/web_file_to_x_file.dart
Welton Moura 0037b0b9cf
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
Initial commit
2026-09-11 15:59:56 -03:00

24 lines
622 B
Dart

// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:async';
import 'dart:typed_data';
import 'package:cross_file/cross_file.dart';
import 'package:universal_html/universal_html.dart' as web;
Future<XFile> webToXFile(web.File file) async {
final reader = web.FileReader();
reader.readAsArrayBuffer(file);
await reader.onLoad.first;
return XFile(
file.relativePath ?? file.name,
name: file.name,
mimeType: file.type,
bytes: reader.result as Uint8List,
);
}