Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions core/src/services/pcloud/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,12 @@ impl PcloudCore {
pub async fn upload_file(&self, path: &str, bs: Bytes) -> Result<Response<IncomingAsyncBody>> {
let path = build_abs_path(&self.root, path);

let paths: Vec<&str> = path.split('/').collect();
let name = paths[paths.len() - 1];
let path = path.replace(&format!("/{}", name), "");
let (name, path) = (get_basename(&path), get_parent(&path).trim_end_matches('/'));

let url = format!(
"{}/uploadfile?path=/{}&filename={}&username={}&password={}",
self.endpoint,
percent_encode_path(&path),
percent_encode_path(path),
percent_encode_path(name),
self.username,
self.password
Expand Down
10 changes: 6 additions & 4 deletions core/src/services/seafile/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ impl SeafileWriter {
#[async_trait]
impl oio::OneShotWrite for SeafileWriter {
async fn write_once(&self, bs: &dyn oio::WriteBuf) -> Result<()> {
let path = build_abs_path(&self.core.root, &self.path);
let bs = oio::ChunkedBytes::from_vec(bs.vectored_bytes(bs.remaining()));

let upload_url = self.core.get_upload_url().await?;

let req = Request::post(upload_url);

let paths = path.split('/').collect::<Vec<&str>>();
let filename = paths[paths.len() - 1];
let relative_path = path.replace(filename, "");
let (filename, relative_path) = if self.path.ends_with('/') {
("", build_abs_path(&self.core.root, &self.path))
} else {
let (filename, relative_path) = (get_basename(&self.path), get_parent(&self.path));
(filename, build_abs_path(&self.core.root, relative_path))
};

let file_part = FormDataPart::new("file")
.header(
Expand Down