Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: do not use Blob for uploading chunks

thecodrr1bbd6179071d
diff --git a/apps/web/desktop/protocol.js b/apps/web/desktop/protocol.js
index 457667647..4c2f23958 100644
--- a/apps/web/desktop/protocol.js
+++ b/apps/web/desktop/protocol.js
@@ -1,4 +1,4 @@
-const { protocol, session } = require("electron");
+const { protocol } = require("electron");
const { isDevelopment, getPath } = require("./utils");
const fs = require("fs");
const path = require("path");
@@ -62,6 +62,7 @@ function registerProtocol() {
redirect: "manual",
});
} catch (e) {
+ console.error(e);
logger.error(`Error sending request to `, request.url, "Error: ", e);
callback({ statusCode: 400 });
return;
@@ -94,13 +95,18 @@ function shouldInterceptRequest(url) {
* @param {Electron.ProtocolRequest} request
*/
async function getBody(request) {
+ /**
+ * @type {Electron.Session}
+ */
+ const session = global.win.webContents.session;
+
const blobParts = [];
if (!request.uploadData || !request.uploadData.length) return null;
for (let data of request.uploadData) {
if (data.type === "rawData") {
blobParts.push(new Uint8Array(data.bytes));
} else if (data.type === "blob") {
- const buffer = await session.defaultSession.getBlobData(data.blobUUID);
+ const buffer = await session.getBlobData(data.blobUUID);
blobParts.push(new Uint8Array(buffer));
}
}
diff --git a/apps/web/src/interfaces/fs.js b/apps/web/src/interfaces/fs.js
index 4c28f526f..b9b49618d 100644
--- a/apps/web/src/interfaces/fs.js
+++ b/apps/web/src/interfaces/fs.js
@@ -213,12 +213,13 @@ async function uploadFile(filename, requestOptions) {
UPLOAD_PART_REQUIRED_CHUNKS
);
const url = parts[i];
+ const data = await blob.arrayBuffer();
const response = await axios.request({
url,
method: "PUT",
headers: { "Content-Type": "" },
cancelToken: cancellationToken,
- data: blob,
+ data,
onUploadProgress,
});
if (!isSuccessStatusCode(response.status) || !response.headers.etag)