Enhance video file handling in file explorer; implement viewer session for authenticated URL and improve error handling for missing file ID.
This commit is contained in:
@@ -901,15 +901,26 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
if (file.type == FileType.folder) {
|
if (file.type == FileType.folder) {
|
||||||
context.read<FileBrowserBloc>().add(NavigateToFolder(file.path));
|
context.read<FileBrowserBloc>().add(NavigateToFolder(file.path));
|
||||||
} else if (isVideo) {
|
} else if (isVideo) {
|
||||||
// Open video files in video viewer
|
// Open video files in video viewer - use viewer session for authenticated URL
|
||||||
final videoUrl = await getIt<FileService>().getDownloadUrl(
|
if (file.id == null || file.id!.isEmpty) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Error: File ID is missing')),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final session = await getIt<FileService>().requestViewerSession(
|
||||||
widget.orgId,
|
widget.orgId,
|
||||||
file.path,
|
file.id!,
|
||||||
);
|
);
|
||||||
_showVideoViewer(
|
_showVideoViewer(file.name, session.viewUrl.toString());
|
||||||
file.name,
|
} catch (e) {
|
||||||
'${getIt<FileService>().baseUrl}$videoUrl',
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Error loading video: $e')),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (file.id == null || file.id!.isEmpty) {
|
if (file.id == null || file.id!.isEmpty) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
|||||||
Reference in New Issue
Block a user