31 lines
1002 B
Dart
31 lines
1002 B
Dart
import 'package:nextcloud/nextcloud.dart';
|
|
|
|
import '../../../model/account_data.dart';
|
|
import '../../../model/endpoint_data.dart';
|
|
import '../../api_request.dart';
|
|
import '../../api_response.dart';
|
|
|
|
abstract class WebdavApi<T> extends ApiRequest {
|
|
T genericParams;
|
|
|
|
WebdavApi(this.genericParams) {
|
|
establishWebdavConnection();
|
|
}
|
|
|
|
Future<ApiResponse> run();
|
|
|
|
static Future<WebDavClient> webdav = establishWebdavConnection();
|
|
|
|
static Future<WebDavClient> establishWebdavConnection() async =>
|
|
NextcloudClient(
|
|
Uri.parse('https://${EndpointData().nextcloud().full()}'),
|
|
password: AccountData().getPassword(),
|
|
loginName: AccountData().getUsername(),
|
|
).webdav;
|
|
|
|
/// Builds the WebDAV download URL without embedded credentials. Callers must
|
|
/// authenticate via the [AccountData.authHeaders] header instead.
|
|
static String buildWebdavUrl() =>
|
|
'https://${EndpointData().nextcloud().full()}/remote.php/dav/files/${AccountData().getUsername()}/';
|
|
}
|