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? lastModified,
final DateTime? created, final DateTime? created,
}) => }) =>
_send( uploadStream(
'PUT', Stream.value(localData),
_constructPath(remotePath), remotePath,
[200, 201, 204], lastModified: lastModified,
data: Stream.value(localData), created: created,
headers: _generateUploadHeaders( contentLength: localData.lengthInBytes,
lastModified: lastModified,
created: created,
contentLength: localData.lengthInBytes,
),
); );
/// upload a new file with [localData] as content to [remotePath] /// 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 /// download [remotePath] and store the response file contents to String
Future<Uint8List> download(final String remotePath) async => Uint8List.fromList( Future<Uint8List> download(final String remotePath) async =>
(await (await _send( Uint8List.fromList((await (await downloadStream(remotePath)).join()).codeUnits);
'GET',
_constructPath(remotePath),
[200],
))
.join())
.codeUnits,
);
/// download [remotePath] and store the response file contents to ByteStream /// download [remotePath] and store the response file contents to ByteStream
Future<HttpClientResponse> downloadStream(final String remotePath) async => _send( Future<HttpClientResponse> downloadStream(final String remotePath) async => _send(

Loading…
Cancel
Save