diff --git a/src/mako/lib/mbuild.mako b/src/mako/lib/mbuild.mako index ed6f8d134ef..1aabbc81260 100644 --- a/src/mako/lib/mbuild.mako +++ b/src/mako/lib/mbuild.mako @@ -361,6 +361,7 @@ match result { Result::HttpError(err) => println!("HTTPERROR: {:?}", err), Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"), Result::MissingToken => println!("OAuth2: Missing Token"), + Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size), Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"), Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field), Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err), @@ -440,7 +441,10 @@ match result { all_required_param_name = set(p.name for p in params if is_required_property(p)) MULTI_SLASH = 'multi-slash-prefix' URL_ENCODE = 'url-encode' - READER_SEEK = "let size = reader.seek(io::SeekFrom::End(0)).unwrap();\nreader.seek(io::SeekFrom::Start(0)).unwrap();" + + max_size = simple_media_param.max_size + READER_SEEK = "let size = reader.seek(io::SeekFrom::End(0)).unwrap();\nreader.seek(io::SeekFrom::Start(0)).unwrap();\n" + READER_SEEK += "if size > %i {\n\treturn Result::UploadSizeLimitExceeded(size, %i)\n}" % (max_size, max_size) special_cases = set() for possible_url in possible_urls: diff --git a/src/rust/cmn.rs b/src/rust/cmn.rs index 3152b0c7cfa..9668f7709c7 100644 --- a/src/rust/cmn.rs +++ b/src/rust/cmn.rs @@ -195,6 +195,10 @@ pub enum Result { /// The http connection failed HttpError(hyper::HttpError), + /// An attempt was made to upload a resource with size stored in field `.0` + /// even though the maximum upload size is what is stored in field `.1`. + UploadSizeLimitExceeded(u64, u64), + /// We needed an API key for authentication, but didn't obtain one. /// Neither through the authenticator, nor through the Delegate. MissingAPIKey,