src/client/http_client.rs: implement upload_stream

This commit is contained in:
Dietmar Maurer
2019-05-20 14:19:24 +02:00
parent 2698e8a514
commit 82ab72304e
3 changed files with 213 additions and 74 deletions

View File

@ -163,6 +163,7 @@ fn backup_api() -> Router {
"dynamic_index", Router::new()
.download(api_method_dynamic_chunk_index())
.post(api_method_create_dynamic_index())
.put(api_method_dynamic_append())
)
.subdir(
"dynamic_close", Router::new()
@ -237,6 +238,40 @@ fn create_dynamic_index(
Ok(json!(wid))
}
pub fn api_method_dynamic_append() -> ApiMethod {
ApiMethod::new(
dynamic_append,
ObjectSchema::new("Append chunk to dynamic index writer.")
.required("digest", StringSchema::new("Chunk digest."))
.required("wid", IntegerSchema::new("Dynamic writer ID.")
.minimum(1)
.maximum(256)
)
)
}
fn dynamic_append (
param: Value,
_info: &ApiMethod,
rpcenv: &mut RpcEnvironment,
) -> Result<Value, Error> {
let wid = tools::required_integer_param(&param, "wid")? as usize;
let digest_str = tools::required_string_param(&param, "digest")?;
let env: &BackupEnvironment = rpcenv.as_ref();
let _size = 0;
let _digest = crate::tools::hex_to_digest(digest_str)?;
// fixme: lookup digest and chunk size, then add
//env.dynamic_writer_append_chunk(wid, size, &digest)?;
env.log(format!("sucessfully added chunk {} to dynamic index {}", digest_str, wid));
Ok(Value::Null)
}
pub fn api_method_close_dynamic_index() -> ApiMethod {
ApiMethod::new(
close_dynamic_index,

View File

@ -110,7 +110,7 @@ pub fn api_method_upload_speedtest() -> ApiAsyncMethod {
fn upload_speedtest(
_parts: Parts,
req_body: Body,
param: Value,
_param: Value,
_info: &ApiAsyncMethod,
rpcenv: Box<RpcEnvironment>,
) -> Result<BoxFut, Error> {