Files
Client/lib/share_intent/remote_file_ref.dart
T

41 lines
1.3 KiB
Dart

import '../api/marianumcloud/talk/chat/get_chat_response.dart';
import '../api/marianumcloud/webdav/queries/list_files/cacheable_file.dart';
/// References a file that already lives on the Nextcloud server. Used by the
/// in-app share/save flows that operate on remote paths instead of local
/// cache files (no upload needed).
class RemoteFileRef {
final String path;
final String name;
/// Nextcloud's instance-local file id, when known. Preferred over [path]
/// for hitting the preview API — the path-based variant is unreliable on
/// some server configurations.
final int? fileId;
/// Server's `nc:has-preview` flag when known. null = unknown.
final bool? hasPreview;
const RemoteFileRef({
required this.path,
required this.name,
this.fileId,
this.hasPreview,
});
/// Caller must verify `file.path != null` first — Talk message parameters
/// without a path (system events, mentions, polls) are not file refs.
factory RemoteFileRef.fromTalk(RichObjectString file) => RemoteFileRef(
path: file.path!,
name: file.name,
fileId: int.tryParse(file.id),
);
factory RemoteFileRef.fromCacheable(CacheableFile file) => RemoteFileRef(
path: file.path,
name: file.name,
fileId: file.fileId,
hasPreview: file.hasPreview,
);
}