diff --git a/package-lock.json b/package-lock.json index 37b5d340..6a51d710 100644 Binary files a/package-lock.json and b/package-lock.json differ diff --git a/package.json b/package.json index c2179329..bb7e7488 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "btoa": "^1.2.1", "cheerio": "^1.0.0-rc.5", "dotenv": "^10.0.0", + "exif-be-gone": "^1.2.0", "express": "^4.17.1", "express-async-errors": "^3.1.1", "file-type": "^16.5.0", diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts index 453133f3..6e74788f 100644 --- a/src/util/FileStorage.ts +++ b/src/util/FileStorage.ts @@ -3,6 +3,8 @@ import fs from "fs"; import fse from "fs-extra"; import { join, relative, dirname } from "path"; import "missing-native-js-functions"; +import { Readable } from "stream"; +import ExifTransformer = require("exif-be-gone"); function getPath(path: string) { // STORAGE_LOCATION has a default value in start.ts @@ -26,7 +28,10 @@ export class FileStorage implements Storage { path = getPath(path); fse.ensureDirSync(dirname(path)); - return fs.writeFileSync(path, value, { encoding: "binary" }); + value = Readable.from(value); + const cleaned_file = fs.createWriteStream(path); + + return value.pipe(new ExifTransformer()).pipe(cleaned_file); } async delete(path: string) {