Browse Source

nextcloud: Cleanup WebDAV upload and download methods

pull/393/head
jld3103 2 years ago
parent
commit
f6d3b4a7bd
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 27
      packages/nextcloud/lib/src/webdav/client.dart

27
packages/nextcloud/lib/src/webdav/client.dart

@ -164,16 +164,12 @@ class WebDavClient {
final DateTime? lastModified,
final DateTime? created,
}) =>
_send(
'PUT',
_constructPath(remotePath),
[200, 201, 204],
data: Stream.value(localData),
headers: _generateUploadHeaders(
lastModified: lastModified,
created: created,
contentLength: localData.lengthInBytes,
),
uploadStream(
Stream.value(localData),
remotePath,
lastModified: lastModified,
created: created,
contentLength: localData.lengthInBytes,
);
/// upload a new file with [localData] as content to [remotePath]
@ -197,15 +193,8 @@ class WebDavClient {
);
/// download [remotePath] and store the response file contents to String
Future<Uint8List> download(final String remotePath) async => Uint8List.fromList(
(await (await _send(
'GET',
_constructPath(remotePath),
[200],
))
.join())
.codeUnits,
);
Future<Uint8List> download(final String remotePath) async =>
Uint8List.fromList((await (await downloadStream(remotePath)).join()).codeUnits);
/// download [remotePath] and store the response file contents to ByteStream
Future<HttpClientResponse> downloadStream(final String remotePath) async => _send(

Loading…
Cancel
Save