This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch stream-based-write in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 6b9c74edaa3b9580967fc4613912ed3b334798de Author: Xuanwo <[email protected]> AuthorDate: Wed Aug 30 18:50:48 2023 +0800 Migrate webdav Signed-off-by: Xuanwo <[email protected]> --- core/src/services/webdav/writer.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/core/src/services/webdav/writer.rs b/core/src/services/webdav/writer.rs index 5050b70cf..50a40d9d5 100644 --- a/core/src/services/webdav/writer.rs +++ b/core/src/services/webdav/writer.rs @@ -36,16 +36,19 @@ impl WebdavWriter { pub fn new(backend: WebdavBackend, op: OpWrite, path: String) -> Self { WebdavWriter { backend, op, path } } +} - async fn write_oneshot(&mut self, size: u64, body: AsyncBody) -> Result<()> { +#[async_trait] +impl oio::Write for WebdavWriter { + async fn write(&mut self, s: oio::Streamer) -> Result<()> { let resp = self .backend .webdav_put( &self.path, - Some(size), + Some(s.size()), self.op.content_type(), self.op.content_disposition(), - body, + AsyncBody::Stream(s), ) .await?; @@ -60,18 +63,6 @@ impl WebdavWriter { } } - async fn write(&mut self, bs: Bytes) -> Result<()> { - self.write_oneshot(bs.len() as u64, AsyncBody::Bytes(bs)) - .await - } -} - -#[async_trait] -impl oio::Write for WebdavWriter { - async fn write(&mut self, s: oio::Streamer) -> Result<()> { - self.write_oneshot(s.size(), AsyncBody::Stream(s)).await - } - async fn abort(&mut self) -> Result<()> { Ok(()) }
