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

Function dataStore

lib/api/apiUtils/object/storeObject.js:58–87  ·  view source on GitHub ↗

* Stores object and responds back with key and storage type * @param {object} objectContext - object's keyContext for sproxyd Key * computation (put API) * @param {object} cipherBundle - cipher bundle that encrypt the data * @param {object} stream - the stream containing the data * @param {numb

(objectContext, cipherBundle, stream, size,
    streamingV4Params, backendInfo, log, cb)

Source from the content-addressed store, hash-verified

56 * @return {undefined}
57 */
58function dataStore(objectContext, cipherBundle, stream, size,
59 streamingV4Params, backendInfo, log, cb) {
60 const cbOnce = jsutil.once(cb);
61 const dataStreamTmp = prepareStream(stream, streamingV4Params, log, cbOnce);
62 if (!dataStreamTmp) {
63 return process.nextTick(() => cb(errors.InvalidArgument));
64 }
65 const dataStream = stripTrailingChecksumStream(dataStreamTmp, log, cbOnce);
66 return data.put(
67 cipherBundle, dataStream, size, objectContext, backendInfo, log,
68 (err, dataRetrievalInfo, hashedStream) => {
69 if (err) {
70 log.error('error in datastore', {
71 error: err,
72 });
73 return cbOnce(err);
74 }
75 if (!dataRetrievalInfo) {
76 log.fatal('data put returned neither an error nor a key', {
77 method: 'storeObject::dataStore',
78 });
79 return cbOnce(errors.InternalError);
80 }
81 log.trace('dataStore: backend stored key', {
82 dataRetrievalInfo,
83 });
84 return checkHashMatchMD5(stream, hashedStream,
85 dataRetrievalInfo, log, cbOnce);
86 });
87}
88
89module.exports = {
90 dataStore,

Callers 4

putDataFunction · 0.85
putObjectFunction · 0.85
objectPutPartFunction · 0.85
createAndStoreObjectFunction · 0.85

Calls 6

prepareStreamFunction · 0.85
errorMethod · 0.80
fatalMethod · 0.80
traceMethod · 0.80
checkHashMatchMD5Function · 0.70

Tested by

no test coverage detected