From 640e519c1fa66893eac8d4fe0a7f0603c0457996 Mon Sep 17 00:00:00 2001 From: Will Toozs Date: Fri, 31 May 2024 15:27:03 +0200 Subject: [PATCH] checkpoint: trying to get file store to work for POST --- lib/auth/v4/formAuthCheck.ts | 30 ++++++++++++++------------ lib/storage/data/DataWrapper.js | 3 +++ lib/storage/data/file/DataFileStore.js | 14 ++++++++++++ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/lib/auth/v4/formAuthCheck.ts b/lib/auth/v4/formAuthCheck.ts index 6e6d824a3..893ae2366 100644 --- a/lib/auth/v4/formAuthCheck.ts +++ b/lib/auth/v4/formAuthCheck.ts @@ -71,20 +71,22 @@ export function check(request: any, log: Logger, data: { [key: string]: string } // building string to sign const payloadChecksum = 'UNSIGNED-PAYLOAD'; - const stringToSign = constructStringToSign({ - log, - request, - query: queryWithoutSignature, - signedHeaders, - payloadChecksum, - timestamp, - credentialScope: - `${scopeDate}/${region}/${service}/${requestType}`, - awsService: service, - }); - if (stringToSign instanceof Error) { - return { err: stringToSign }; - } + // const stringToSign = constructStringToSign({ + // log, + // request, + // query: queryWithoutSignature, + // signedHeaders, + // payloadChecksum, + // timestamp, + // credentialScope: + // `${scopeDate}/${region}/${service}/${requestType}`, + // awsService: service, + // }); + // if (stringToSign instanceof Error) { + // return { err: stringToSign }; + // } + // string to sign is the policy + const stringToSign = data['Policy']; log.trace('constructed stringToSign', { stringToSign }); return { err: null, diff --git a/lib/storage/data/DataWrapper.js b/lib/storage/data/DataWrapper.js index ad8255748..a4dafd8b4 100644 --- a/lib/storage/data/DataWrapper.js +++ b/lib/storage/data/DataWrapper.js @@ -921,6 +921,9 @@ class DataWrapper { }); let hashedStream = null; if (value) { + // if (value.isPaused()) { + // value.resume(); + // } hashedStream = new MD5Sum(); value.pipe(hashedStream); value.once('clientError', () => { diff --git a/lib/storage/data/file/DataFileStore.js b/lib/storage/data/file/DataFileStore.js index a17192ae3..a92a5ba31 100644 --- a/lib/storage/data/file/DataFileStore.js +++ b/lib/storage/data/file/DataFileStore.js @@ -249,7 +249,21 @@ class DataFileStore { `write stream error: ${err.code}`)); }); dataStream.resume(); + + const originalWrite = fileStream.write; + fileStream.write = function(chunk, encoding, callback) { + console.log('Data chunk:', chunk); + return originalWrite.call(this, chunk, encoding, callback); + }; +// dataStream.on('end', () => { +// fileStream.end(); +// }); dataStream.pipe(fileStream); + // dataStream.on('data', (data) => { + // console.log(data); + // fileStream.write(data); + // }) + dataStream.on('error', err => { log.error('error streaming data on read', { method: 'put', key, filePath, error: err });