mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-10 06:25:00 +00:00
Set content-length in PutObject, CompleteMultipart
This commit is contained in:
parent
595844c36d
commit
c1127b4117
1 changed files with 14 additions and 3 deletions
|
@ -210,7 +210,9 @@ impl Store for ObjectStore {
|
||||||
|
|
||||||
if first_chunk.len() < CHUNK_SIZE {
|
if first_chunk.len() < CHUNK_SIZE {
|
||||||
drop(stream);
|
drop(stream);
|
||||||
let (req, object_id) = self.put_object_request(content_type).await?;
|
let (req, object_id) = self
|
||||||
|
.put_object_request(first_chunk.len(), content_type)
|
||||||
|
.await?;
|
||||||
let response = req
|
let response = req
|
||||||
.body(Body::wrap_stream(first_chunk))
|
.body(Body::wrap_stream(first_chunk))
|
||||||
.send()
|
.send()
|
||||||
|
@ -340,7 +342,7 @@ impl Store for ObjectStore {
|
||||||
bytes: Bytes,
|
bytes: Bytes,
|
||||||
content_type: mime::Mime,
|
content_type: mime::Mime,
|
||||||
) -> Result<Self::Identifier, StoreError> {
|
) -> Result<Self::Identifier, StoreError> {
|
||||||
let (req, object_id) = self.put_object_request(content_type).await?;
|
let (req, object_id) = self.put_object_request(bytes.len(), content_type).await?;
|
||||||
|
|
||||||
let response = req.body(bytes).send().await.map_err(ObjectError::from)?;
|
let response = req.body(bytes).send().await.map_err(ObjectError::from)?;
|
||||||
|
|
||||||
|
@ -495,6 +497,7 @@ impl ObjectStore {
|
||||||
|
|
||||||
async fn put_object_request(
|
async fn put_object_request(
|
||||||
&self,
|
&self,
|
||||||
|
length: usize,
|
||||||
content_type: mime::Mime,
|
content_type: mime::Mime,
|
||||||
) -> Result<(RequestBuilder, ObjectId), StoreError> {
|
) -> Result<(RequestBuilder, ObjectId), StoreError> {
|
||||||
let path = self.next_file().await?;
|
let path = self.next_file().await?;
|
||||||
|
@ -504,6 +507,9 @@ impl ObjectStore {
|
||||||
action
|
action
|
||||||
.headers_mut()
|
.headers_mut()
|
||||||
.insert("content-type", content_type.as_ref());
|
.insert("content-type", content_type.as_ref());
|
||||||
|
action
|
||||||
|
.headers_mut()
|
||||||
|
.insert("content-length", length.to_string());
|
||||||
|
|
||||||
Ok((self.build_request(action), ObjectId::from_string(path)))
|
Ok((self.build_request(action), ObjectId::from_string(path)))
|
||||||
}
|
}
|
||||||
|
@ -588,7 +594,12 @@ impl ObjectStore {
|
||||||
|
|
||||||
let (req, action) = self.build_request_inner(action);
|
let (req, action) = self.build_request_inner(action);
|
||||||
|
|
||||||
req.body(action.body()).send().await
|
let body: Vec<u8> = action.body().into();
|
||||||
|
|
||||||
|
req.header(CONTENT_LENGTH, body.len())
|
||||||
|
.body(body)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_abort_multipart_request(
|
fn create_abort_multipart_request(
|
||||||
|
|
Loading…
Reference in a new issue