diff --git a/src/blobs.jl b/src/blobs.jl index fd56292..9cc8902 100644 --- a/src/blobs.jl +++ b/src/blobs.jl @@ -60,7 +60,12 @@ API.startMultipartUpload(x::Container, key; kw...) = nothing function API.uploadPart(x::Container, url, part, partNumber, uploadId; kw...) blockid = base64encode(lpad(partNumber - 1, 64, '0')) resp = Azure.put(url, [], part; query=Dict("comp" => "block", "blockid" => blockid), kw...) - return (blockid, resp.metrics.request_body_length) + body_length = if hasproperty(resp, :metrics) + resp.metrics.request_body_length + else + Base.get(resp.request.context, :nbytes_written, 0) + end + return (blockid, body_length) end function API.completeMultipartUpload(x::Container, url, eTags, uploadId; kw...) diff --git a/src/get.jl b/src/get.jl index 011fe82..e488a5d 100644 --- a/src/get.jl +++ b/src/get.jl @@ -226,11 +226,21 @@ function getObjectImpl(x::AbstractStore, key::String, out::ResponseBodyType=noth # directly as HTTP receives the response body _res = view(res, _rng) r = getObject(x, url, _headers; response_stream=_res, kw...) - Threads.atomic_add!(nbytes, r.metrics.response_body_length) + body_length = if hasproperty(resp, :metrics) + resp.metrics.request_body_length + else + contentLength + end + Threads.atomic_add!(nbytes, body_length) else buf = view(buffers[$i], 1:min(partSize, length(rng))) r = getObject(x, url, _headers; response_stream=buf, kw...) - Threads.atomic_add!(nbytes, r.metrics.response_body_length) + body_length = if hasproperty(resp, :metrics) + resp.metrics.request_body_length + else + contentLength + end + Threads.atomic_add!(nbytes, body_length) put!(() -> write(body, buf), sync, _n) end end