Skip to content

Commit

Permalink
checkpoint: trying to get file store to work for POST
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Toozs committed May 31, 2024
1 parent 50f2435 commit 640e519
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lib/auth/v4/formAuthCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions lib/storage/data/DataWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
14 changes: 14 additions & 0 deletions lib/storage/data/file/DataFileStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,21 @@ class DataFileStore {
`write stream error: ${err.code}`));
});
dataStream.resume();

const originalWrite = fileStream.write;
fileStream.write = function(chunk, encoding, callback) {

Check warning on line 254 in lib/storage/data/file/DataFileStore.js

View workflow job for this annotation

GitHub Actions / test

Unexpected unnamed function

Check failure on line 254 in lib/storage/data/file/DataFileStore.js

View workflow job for this annotation

GitHub Actions / test

Missing space before function parentheses
console.log('Data chunk:', chunk);

Check failure on line 255 in lib/storage/data/file/DataFileStore.js

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
return originalWrite.call(this, chunk, encoding, callback);
};
// dataStream.on('end', () => {

Check failure on line 258 in lib/storage/data/file/DataFileStore.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 12 spaces but found 0
// fileStream.end();

Check failure on line 259 in lib/storage/data/file/DataFileStore.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 12 spaces but found 0
// });

Check failure on line 260 in lib/storage/data/file/DataFileStore.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 12 spaces but found 0
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 });
Expand Down

0 comments on commit 640e519

Please sign in to comment.