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) => {