@@ -142,17 +142,14 @@ class WebDavClient {
142
142
143
143
/// Request to put a new file at [path] with [localData] as content.
144
144
///
145
- /// Setting [contentLength] is important because some web servers will consider the file to be empty otherwise.
146
- /// It will be required in the next major release.
147
- ///
148
145
/// See:
149
146
/// * [putStream] for a complete operation executing this request.
150
147
http.BaseRequest putStream_Request (
151
148
Stream <List <int >> localData,
152
149
PathUri path, {
150
+ required int contentLength,
153
151
DateTime ? lastModified,
154
152
DateTime ? created,
155
- int ? contentLength,
156
153
void Function (double progress)? onProgress,
157
154
}) {
158
155
final request = http.StreamedRequest ('PUT' , _constructUri (path));
@@ -165,7 +162,7 @@ class WebDavClient {
165
162
contentLength: contentLength,
166
163
);
167
164
168
- if (contentLength != null && onProgress != null ) {
165
+ if (onProgress != null ) {
169
166
var uploaded = 0 ;
170
167
171
168
unawaited (
@@ -190,18 +187,16 @@ class WebDavClient {
190
187
/// [created] sets the date when the file was created on the server.
191
188
/// [contentLength] sets the length of the [localData] that is uploaded.
192
189
/// [onProgress] can be used to watch the upload progress. Possible values range from 0.0 to 1.0. [contentLength] needs to be set for it to work.
193
- /// Setting [contentLength] is important because some web servers will consider the file to be empty otherwise.
194
- /// It will be required in the next major release.
195
190
///
196
191
/// See:
197
192
/// * http://www.webdav.org/specs/rfc2518.html#METHOD_PUT for more information.
198
193
/// * [putStream_Request] for the request sent by this method.
199
194
Future <http.StreamedResponse > putStream (
200
195
Stream <List <int >> localData,
201
196
PathUri path, {
197
+ required int contentLength,
202
198
DateTime ? lastModified,
203
199
DateTime ? created,
204
- int ? contentLength,
205
200
void Function (double progress)? onProgress,
206
201
}) {
207
202
final request = putStream_Request (
@@ -575,19 +570,17 @@ class WebDavClient {
575
570
576
571
static void _addUploadHeaders (
577
572
http.BaseRequest request, {
573
+ required int contentLength,
578
574
DateTime ? lastModified,
579
575
DateTime ? created,
580
- int ? contentLength,
581
576
}) {
582
577
if (lastModified != null ) {
583
578
request.headers['X-OC-Mtime' ] = lastModified.secondsSinceEpoch.toString ();
584
579
}
585
580
if (created != null ) {
586
581
request.headers['X-OC-CTime' ] = created.secondsSinceEpoch.toString ();
587
582
}
588
- if (contentLength != null ) {
589
- request.headers['content-length' ] = contentLength.toString ();
590
- }
583
+ request.headers['content-length' ] = contentLength.toString ();
591
584
}
592
585
593
586
void _addCopyHeaders (http.BaseRequest request, {required PathUri destinationPath, required bool overwrite}) {
0 commit comments