* 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)
| 56 | * @return {undefined} |
| 57 | */ |
| 58 | function 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 | |
| 89 | module.exports = { |
| 90 | dataStore, |
no test coverage detected