diff --git a/Crypter.Web/wwwroot/chromiumFetchTest/script.js b/Crypter.Web/wwwroot/chromiumFetchTest/script.js index 40728fff1..810947e13 100644 --- a/Crypter.Web/wwwroot/chromiumFetchTest/script.js +++ b/Crypter.Web/wwwroot/chromiumFetchTest/script.js @@ -10,16 +10,24 @@ function wait(milliseconds) { return new Promise(resolve => setTimeout(resolve, milliseconds)); } -const boundaryText = 'CustomBoundary'; +const boundaryText = '4c4b7e34-dc34-4971-913c-6b6ceb09ee33'; function uploadAsync(file) { const readableStream = new ReadableStream({ async start(controller) { - controller.enqueue(`\r\n--${boundaryText}\r\n`); - controller.enqueue('Data={"Filename":"test.txt", "ContentType":"text/csv", "PublicKey":"nxC6b2L5fWjLROFbNMmBxRX1GSC3nCSwU/GaM3hC4hk=", "KeyExchangeNonce":"JAdv1MbzC7BGNiWfC+3JTinCEhf/+JUl0ySNeQfC7q4=", "Proof":"i51Bn7mHZDcZ0u4xnd1CtyEL9RXJDjheogPHrv2vB5c=", "LifetimeHours":24};type=application/json'); - controller.enqueue(`\r\n--${boundaryText}\r\n`); - controller.enqueue('Ciphertext=') - + controller.enqueue(`--${boundaryText}`); + controller.enqueue('\r\n'); + controller.enqueue('Content-Type: application/json; charset=utf-8'); + controller.enqueue('\r\n'); + controller.enqueue('Content-Disposition: form-data; name=Data'); + controller.enqueue('\r\n\r\n'); + controller.enqueue('{"Filename":"test.txt", "ContentType":"text/csv", "PublicKey":"nxC6b2L5fWjLROFbNMmBxRX1GSC3nCSwU/GaM3hC4hk=", "KeyExchangeNonce":"JAdv1MbzC7BGNiWfC+3JTinCEhf/+JUl0ySNeQfC7q4=", "Proof":"i51Bn7mHZDcZ0u4xnd1CtyEL9RXJDjheogPHrv2vB5c=", "LifetimeHours":24}'); + controller.enqueue('\r\n'); + controller.enqueue(`--${boundaryText}`); + controller.enqueue('\r\n'); + controller.enqueue('Content-Disposition: form-data; name=Ciphertext; filename=Ciphertext; filename*=utf-8\'\'Ciphertext'); + controller.enqueue('\r\n\r\n'); + const reader = file.stream().getReader(); async function pushAsync() { @@ -33,7 +41,9 @@ function uploadAsync(file) { }); } await pushAsync(); - controller.enqueue(`\r\n--${boundaryText}--`); + controller.enqueue('\r\n'); + controller.enqueue(`--${boundaryText}--`); + controller.enqueue('\r\n\r\n'); controller.close(); }