MCPcopy Index your code
hub / github.com/scality/cloudserver / prepareStream

Function prepareStream

lib/api/apiUtils/object/prepareStream.js:16–32  ·  view source on GitHub ↗

* Prepares the stream if the chunks are sent in a v4 Auth request * @param {object} stream - stream containing the data * @param {object | null } streamingV4Params - if v4 auth, object containing * accessKey, signatureFromRequest, region, scopeDate, timestamp, and * credentialScope (to be used f

(stream, streamingV4Params, log, errCb)

Source from the content-addressed store, hash-verified

14 * the type of request requires them
15 */
16function prepareStream(stream, streamingV4Params, log, errCb) {
17 if (stream.headers['x-amz-content-sha256'] ===
18 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD') {
19 if (typeof streamingV4Params !== 'object') {
20 // this might happen if the user provided a valid V2
21 // Authentication header, while the chunked upload method
22 // requires V4: in such case we don't get any V4 params
23 // and we should return an error to the client.
24 return null;
25 }
26 const v4Transform = new V4Transform(streamingV4Params, log, errCb);
27 stream.pipe(v4Transform);
28 v4Transform.headers = stream.headers;
29 return v4Transform;
30 }
31 return stream;
32}
33
34function stripTrailingChecksumStream(stream, log) {
35 // don't do anything if we are not in the correct integrity check mode

Callers 2

receiveDataFunction · 0.85
dataStoreFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected