diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2017-11-24 15:13:33 -0500 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2017-11-24 15:13:33 -0500 |
commit | 759312b12344e27e9bcec318453eb9f66616d24c (patch) | |
tree | 0e254af7a6e07456255635037654195a21648148 | |
parent | 8afe22320bee8c28d820dafc5fe25ae4343e95a4 (diff) |
add block put command
-rw-r--r-- | ipfs-api/src/client.rs | 16 | ||||
-rw-r--r-- | ipfs-api/src/request/block.rs | 12 |
2 files changed, 25 insertions, 3 deletions
diff --git a/ipfs-api/src/client.rs b/ipfs-api/src/client.rs index 04e1f99..c583f35 100644 --- a/ipfs-api/src/client.rs +++ b/ipfs-api/src/client.rs @@ -363,9 +363,19 @@ impl IpfsClient { self.request_bytes(&request::BlockGet { hash }, None) } - // TODO - // pub fn block_put(&self, ...) -> AsyncResponse<response::BlockPutResponse> { - // } + /// Store input as an IPFS block. + /// + #[inline] + pub fn block_put<R>(&self, data: R) -> AsyncResponse<response::BlockPutResponse> + where + R: 'static + Read + Send, + { + let mut form = multipart::Form::default(); + + form.add_reader("data", data); + + self.request(&request::BlockPut, Some(form)) + } /// Removes an IPFS block. /// diff --git a/ipfs-api/src/request/block.rs b/ipfs-api/src/request/block.rs index 87cfe54..8409e0f 100644 --- a/ipfs-api/src/request/block.rs +++ b/ipfs-api/src/request/block.rs @@ -23,6 +23,18 @@ impl<'a> ApiRequest for BlockGet<'a> { } +pub struct BlockPut; + +impl_skip_serialize!(BlockPut); + +impl ApiRequest for BlockPut { + #[inline] + fn path() -> &'static str { + "/block/put" + } +} + + #[derive(Serialize)] pub struct BlockRm<'a> { #[serde(rename = "arg")] |