changeset 116:990d95209b35

http: Enhance set_max_chunksize
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 25 Oct 2020 14:11:14 +0100
parents 724c8fbd071c
children d825e5e57818
files async-google-apis-common/src/http.rs
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/async-google-apis-common/src/http.rs	Sun Oct 25 13:10:20 2020 +0100
+++ b/async-google-apis-common/src/http.rs	Sun Oct 25 14:11:14 2020 +0100
@@ -285,8 +285,13 @@
             _resp: Default::default(),
         }
     }
-    pub fn set_max_chunksize(&mut self, size: usize) {
-        self.max_chunksize = size;
+    pub fn set_max_chunksize(&mut self, size: usize) -> Result<&mut Self> {
+        if size % (1024*256) != 0 {
+            Err(ApiError::InputDataError("ResumableUpload: max_chunksize must be multiple of 256 KiB.".into()).into())
+        } else {
+            self.max_chunksize = size;
+            Ok(self)
+        }
     }
 
     /// Upload data from a reader; use only if the reader cannot be seeked. Memory usage is higher,