cuichenli commented on code in PR #1801:
URL:
https://github.com/apache/incubator-opendal/pull/1801#discussion_r1152822268
##########
core/src/services/gcs/backend.rs:
##########
@@ -625,6 +641,85 @@ impl GcsBackend {
self.client.send_async(req).await
}
+
+ async fn gcs_initiate_multipart_upload(
+ &self,
+ path: &str,
+ ) -> Result<Response<IncomingAsyncBody>> {
+ let p = build_abs_path(&self.root, path);
+ let url = format!("{}/{}/{}?uploads", self.endpoint, self.bucket, p);
+ let mut req = Request::post(&url)
+ .body(AsyncBody::Empty)
+ .map_err(new_request_build_error)?;
+ self.signer.sign(&mut req).map_err(new_request_sign_error)?;
+ self.client.send_async(req).await
+ }
+
+ pub fn gcs_upload_part_request(
+ &self,
+ path: &str,
+ upload_id: &str,
+ part_number: usize,
+ size: Option<u64>,
+ body: AsyncBody,
+ ) -> Result<Request<AsyncBody>> {
+ let p = build_abs_path(&self.root, path);
+ let url = format!(
+ "{}/{}/{}?partNumber={}&uploadId={}",
Review Comment:
Just quickly checked the resumable upload document, and noticed that to use
it we need to either:
1. know the file size in advance
2. or indicate the last part by the user (with streaming upload
>Since you don't know the total file size until you get to the final chunk,
use a * for the total file size in the Content-Range header of intermediate
chunks.
>
> For example, if the first chunk you upload has a size of 512 KiB, the
Content-Range header for the chunk is bytes 0-524287/*. If your upload has
64000 bytes remaining after the first chunk, you then send a final chunk that
contains the remaining bytes and has a Content-Range header with the value
bytes 524288-588287/588288.
I don't think the method 1 is feasible, for method 2, we then need to add
one extra parameter for the `append` method to indicate the last part.
Alternatively, we can try in the `close` method upload one empty chunk - I
am not sure if that is feasible yet though.
Anyway, I will convert this PR to draft for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]