From e010fe47cc2dfeb30408801f0bacf72515d88b9f Mon Sep 17 00:00:00 2001 From: Nachtalb Date: Tue, 13 Apr 2021 20:45:16 +0200 Subject: [PATCH] Respect metadata removal switch --- client/js/upload.js | 1 + src/plugins/uploader.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/client/js/upload.js b/client/js/upload.js index a651eeff..faec57e6 100644 --- a/client/js/upload.js +++ b/client/js/upload.js @@ -180,6 +180,7 @@ class Uploader { }; const formData = new FormData(); + formData.append("removeMetadata", store.state.settings.removeImageMetadata); formData.append("file", file); this.xhr.open("POST", `uploads/new/${token}`); this.xhr.send(formData); diff --git a/src/plugins/uploader.js b/src/plugins/uploader.js index 61555619..249aa579 100644 --- a/src/plugins/uploader.js +++ b/src/plugins/uploader.js @@ -130,6 +130,7 @@ class Uploader { let destDir; let destPath; let streamWriter; + let removeMetadata; const doneCallback = () => { // detach the stream and drain any remaining data @@ -207,6 +208,11 @@ class Uploader { busboyInstance.on("partsLimit", () => abortWithError(Error("Parts limit reached"))); busboyInstance.on("filesLimit", () => abortWithError(Error("Files limit reached"))); busboyInstance.on("fieldsLimit", () => abortWithError(Error("Fields limit reached"))); + busboyInstance.on("field", (fieldname, val) => { + if (fieldname === "removeMetadata") { + removeMetadata = val === "true"; + } + }); // generate a random output filename for the file // we use do/while loop to prevent the rare case of generating a file name @@ -260,6 +266,10 @@ class Uploader { sequentialRead: true, }); + if (!removeMetadata) { + sharpInstance = sharpInstance.withMetadata(); + } + sharpInstance .rotate() // auto-orient based on the EXIF Orientation tag .toFile(destPath, (err) => {