diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-12-09 20:09:28 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-12-18 17:59:08 +0100 |
commit | 1853a05a3774344bd039743b068a0efe630d25e4 (patch) | |
tree | 0829dd6389e2ee2291c942cf5c5dc8820b40f2bb | |
parent | 19233255c0b4266895c36a7d5d52eca5f9d55b83 (diff) |
Rewrite Client::post_text_blob() to use add()add-files
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | lib/src/client.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/src/client.rs b/lib/src/client.rs index d985769..918fa90 100644 --- a/lib/src/client.rs +++ b/lib/src/client.rs @@ -42,10 +42,14 @@ impl Client { } pub async fn post_text_blob(&self, text: String) -> Result<Cid> { - self.ipfs - .put_dag(text.into()) + use futures::stream::StreamExt; + + crate::add::add(self.ipfs.clone(), std::io::Cursor::new(text)) + .collect::<Vec<Result<cid::Cid>>>() .await - .map_err(anyhow::Error::from) + .into_iter() + .collect::<Result<Vec<_>>>() + .map(|mut v| v.pop().unwrap()) } /// Post a text node |