(request, response, log, callback)
| 876 | } |
| 877 | |
| 878 | function putObject(request, response, log, callback) { |
| 879 | const err = _checkMultipleBackendRequest(request, log); |
| 880 | if (err) { |
| 881 | return callback(err); |
| 882 | } |
| 883 | const storageLocation = request.headers['x-scal-storage-class']; |
| 884 | const sourceVersionId = request.headers['x-scal-version-id']; |
| 885 | const canonicalID = request.headers['x-scal-canonical-id']; |
| 886 | const contentMD5 = request.headers['content-md5']; |
| 887 | const contentType = request.headers['x-scal-content-type']; |
| 888 | const userMetadata = request.headers['x-scal-user-metadata']; |
| 889 | const cacheControl = request.headers['x-scal-cache-control']; |
| 890 | const contentDisposition = request.headers['x-scal-content-disposition']; |
| 891 | const contentEncoding = request.headers['x-scal-content-encoding']; |
| 892 | const tagging = request.headers['x-scal-tags']; |
| 893 | const metaHeaders = { 'x-amz-meta-scal-replication-status': 'REPLICA' }; |
| 894 | if (sourceVersionId) { |
| 895 | metaHeaders['x-amz-meta-scal-version-id'] = sourceVersionId; |
| 896 | } |
| 897 | if (userMetadata !== undefined) { |
| 898 | try { |
| 899 | const metaData = JSON.parse(userMetadata); |
| 900 | Object.assign(metaHeaders, metaData); |
| 901 | } catch { |
| 902 | // FIXME: add error type MalformedJSON |
| 903 | return callback(errors.MalformedPOSTRequest); |
| 904 | } |
| 905 | } |
| 906 | const context = { |
| 907 | bucketName: request.bucketName, |
| 908 | owner: canonicalID, |
| 909 | namespace: NAMESPACE, |
| 910 | objectKey: request.objectKey, |
| 911 | metaHeaders, |
| 912 | contentType, |
| 913 | cacheControl, |
| 914 | contentDisposition, |
| 915 | contentEncoding, |
| 916 | }; |
| 917 | if (tagging !== undefined) { |
| 918 | try { |
| 919 | const tags = JSON.parse(request.headers['x-scal-tags']); |
| 920 | context.tagging = querystring.stringify(tags); |
| 921 | } catch { |
| 922 | // FIXME: add error type MalformedJSON |
| 923 | return callback(errors.MalformedPOSTRequest); |
| 924 | } |
| 925 | } |
| 926 | const payloadLen = parseInt(request.headers['content-length'], 10); |
| 927 | const backendInfo = new BackendInfo(config, storageLocation); |
| 928 | return dataStore(context, CIPHER, request, payloadLen, {}, backendInfo, log, (err, retrievalInfo, md5) => { |
| 929 | if (err) { |
| 930 | log.error('error putting data', { |
| 931 | error: err, |
| 932 | method: 'putObject', |
| 933 | }); |
| 934 | return callback(err); |
| 935 | } |
nothing calls this directly
no test coverage detected