summaryrefslogtreecommitdiffstats
path: root/ipfs-api/src/client/internal.rs
diff options
context:
space:
mode:
authorJulius Michaelis <gitter@liftm.de>2020-07-12 21:24:55 +0900
committerJulius Michaelis <gitter@liftm.de>2020-07-12 21:24:55 +0900
commitb84a4be646ce2c781b44954989cc02c747794916 (patch)
treee5b6845974de3defcf937e1f92ad9000455fab8b /ipfs-api/src/client/internal.rs
parent71f85fc597dd5c5128c61837f50b75a25a00699f (diff)
parentec9c5269467537db4916eab6d5163f6e8b92fbaa (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'ipfs-api/src/client/internal.rs')
-rw-r--r--ipfs-api/src/client/internal.rs42
1 files changed, 40 insertions, 2 deletions
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs
index d59288c..885f6a4 100644
--- a/ipfs-api/src/client/internal.rs
+++ b/ipfs-api/src/client/internal.rs
@@ -444,11 +444,49 @@ impl IpfsClient {
where
R: 'static + Read + Send + Sync,
{
+ self.add_with_options(data, request::Add::default()).await
+ }
+
+ /// Add a file to IPFS with options.
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// # extern crate ipfs_api;
+ /// #
+ /// use ipfs_api::IpfsClient;
+ /// use std::io::Cursor;
+ ///
+ /// # fn main() {
+ /// let client = IpfsClient::default();
+ /// let data = Cursor::new("Hello World!");
+ /// #[cfg(feature = "builder")]
+ /// let add = ipfs_api::request::Add::builder()
+ /// .chunker("rabin-512-1024-2048")
+ /// .build();
+ /// #[cfg(not(feature = "builder"))]
+ /// let add = ipfs_api::request::Add {
+ /// chunker: Some("rabin-512-1024-2048"),
+ /// ..Default::default()
+ /// };
+ /// let req = client.add_with_options(data, add);
+ /// # }
+ /// ```
+ ///
+ #[inline]
+ pub async fn add_with_options<R>(
+ &self,
+ data: R,
+ add: request::Add<'_>,
+ ) -> Result<response::AddResponse, Error>
+ where
+ R: 'static + Read + Send + Sync,
+ {
let mut form = multipart::Form::default();
form.add_reader("path", data);
- self.request(request::Add, Some(form)).await
+ self.request(add, Some(form)).await
}
/// Add a path to Ipfs. Can be a file or directory.
@@ -515,7 +553,7 @@ impl IpfsClient {
}
}
- let req = self.build_base_request(request::Add, Some(form))?;
+ let req = self.build_base_request(request::Add::default(), Some(form))?;
self.request_stream_json(req).try_collect().await
}