37 lines
962 B
Dart
37 lines
962 B
Dart
import '../models/file_item.dart';
|
|
import '../repositories/file_repository.dart';
|
|
|
|
class FileService {
|
|
final FileRepository _fileRepository;
|
|
|
|
FileService(this._fileRepository);
|
|
|
|
Future<List<FileItem>> getFiles(String orgId, String path) async {
|
|
if (path.isEmpty) {
|
|
throw Exception('Path cannot be empty');
|
|
}
|
|
return await _fileRepository.getFiles(orgId, path);
|
|
}
|
|
|
|
Future<FileItem?> getFile(String orgId, String path) async {
|
|
if (path.isEmpty) {
|
|
return null;
|
|
}
|
|
return await _fileRepository.getFile(orgId, path);
|
|
}
|
|
|
|
Future<void> uploadFile(String orgId, FileItem file) async {
|
|
if (file.name.isEmpty) {
|
|
throw Exception('File name cannot be empty');
|
|
}
|
|
await _fileRepository.uploadFile(orgId, file);
|
|
}
|
|
|
|
Future<void> deleteFile(String orgId, String path) async {
|
|
if (path.isEmpty) {
|
|
throw Exception('Path cannot be empty');
|
|
}
|
|
await _fileRepository.deleteFile(orgId, path);
|
|
}
|
|
}
|