Browse Source

nextcloud: Add Content-Length headers for uploading

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

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

@ -141,6 +141,7 @@ class WebDavClient {
Map<String, String>? _generateUploadHeaders({
required final DateTime? lastModified,
required final DateTime? created,
required final int? contentLength,
}) {
final headers = <String, String>{
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,
),
);

Loading…
Cancel
Save