From bf3b0b187cb6db67ff1fc536e4a9f94f09681831 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 21 May 2023 21:43:37 +0200 Subject: [PATCH] nextcloud: Add Content-Length headers for uploading --- packages/nextcloud/lib/src/webdav/client.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/nextcloud/lib/src/webdav/client.dart b/packages/nextcloud/lib/src/webdav/client.dart index 1c345f1f..86e44b4c 100644 --- a/packages/nextcloud/lib/src/webdav/client.dart +++ b/packages/nextcloud/lib/src/webdav/client.dart @@ -141,6 +141,7 @@ class WebDavClient { Map? _generateUploadHeaders({ required final DateTime? lastModified, required final DateTime? created, + required final int? contentLength, }) { final headers = { if (lastModified != null) ...{ @@ -149,6 +150,9 @@ class WebDavClient { if (created != null) ...{ 'X-OC-CTime': (created.millisecondsSinceEpoch ~/ 1000).toString(), }, + if (contentLength != null) ...{ + 'Content-Length': contentLength.toString(), + }, }; return headers.isNotEmpty ? headers : null; } @@ -168,6 +172,7 @@ class WebDavClient { headers: _generateUploadHeaders( lastModified: lastModified, created: created, + contentLength: localData.lengthInBytes, ), ); @@ -177,6 +182,7 @@ class WebDavClient { final String remotePath, { final DateTime? lastModified, final DateTime? created, + final int? contentLength, }) async => _send( 'PUT', @@ -186,6 +192,7 @@ class WebDavClient { headers: _generateUploadHeaders( lastModified: lastModified, created: created, + contentLength: contentLength, ), );