diff options
author | xnacly <matteogropp@protonmail.com> | 2021-08-10 16:51:45 +0200 |
---|---|---|
committer | xnacly <matteogropp@protonmail.com> | 2021-08-10 16:51:45 +0200 |
commit | e8052ce7fc8c37cd8b34cfeb3cd3aeea1f292afe (patch) | |
tree | 6b02eadf0e4568acb144a6a2e2273894cc646450 | |
parent | :sparkles: ping route (diff) | |
download | server-e8052ce7fc8c37cd8b34cfeb3cd3aeea1f292afe.tar.xz |
added removal of metadata
includes all posted assets
-rw-r--r-- | package-lock.json | 62 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/util/FileStorage.ts | 7 |
3 files changed, 69 insertions, 1 deletions
diff --git a/package-lock.json b/package-lock.json index 37b5d340..6a51d710 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,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", @@ -90,6 +91,11 @@ "@types/node": "*" } }, + "node_modules/@types/chai": { + "version": "4.2.21", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.21.tgz", + "integrity": "sha512-yd+9qKmJxm496BOV9CMNaey8TWsikaZOwMRwPHQIjcOJM9oV+fi9ZMNw3JsVnbEEbo2gRTDnGEBv8pjyn67hNg==" + }, "node_modules/@types/connect": { "version": "3.4.34", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.34.tgz", @@ -160,6 +166,11 @@ "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==", "dev": true }, + "node_modules/@types/mocha": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", + "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==" + }, "node_modules/@types/mongodb": { "version": "3.6.17", "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.17.tgz", @@ -249,6 +260,14 @@ "@types/node": "*" } }, + "node_modules/@types/stream-buffers": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/stream-buffers/-/stream-buffers-3.0.4.tgz", + "integrity": "sha512-qU/K1tb2yUdhXkLIATzsIPwbtX6BpZk0l3dPW6xqWyhfzzM1ECaQ/8faEnu3CNraLiQ9LHyQQPBGp7N9Fbs25w==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/uuid": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", @@ -770,6 +789,20 @@ "node": ">= 0.6" } }, + "node_modules/exif-be-gone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/exif-be-gone/-/exif-be-gone-1.2.0.tgz", + "integrity": "sha512-FIfhEo2jJwXX94iLIONdxm2koKKarpwN6E8wMk8nfgTjRFZySMZRoWzWUvUEaTK+L6iAOzHpSNv4mgdL1JlLdQ==", + "dependencies": { + "@types/chai": "^4.2.12", + "@types/mocha": "^8.0.2", + "@types/node": "^14.0.27", + "@types/stream-buffers": "^3.0.3" + }, + "bin": { + "exif-be-gone": "cli.js" + } + }, "node_modules/express": { "version": "4.17.1", "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", @@ -1962,6 +1995,11 @@ "@types/node": "*" } }, + "@types/chai": { + "version": "4.2.21", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.21.tgz", + "integrity": "sha512-yd+9qKmJxm496BOV9CMNaey8TWsikaZOwMRwPHQIjcOJM9oV+fi9ZMNw3JsVnbEEbo2gRTDnGEBv8pjyn67hNg==" + }, "@types/connect": { "version": "3.4.34", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.34.tgz", @@ -2031,6 +2069,11 @@ "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==", "dev": true }, + "@types/mocha": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", + "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==" + }, "@types/mongodb": { "version": "3.6.17", "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.17.tgz", @@ -2120,6 +2163,14 @@ "@types/node": "*" } }, + "@types/stream-buffers": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/stream-buffers/-/stream-buffers-3.0.4.tgz", + "integrity": "sha512-qU/K1tb2yUdhXkLIATzsIPwbtX6BpZk0l3dPW6xqWyhfzzM1ECaQ/8faEnu3CNraLiQ9LHyQQPBGp7N9Fbs25w==", + "requires": { + "@types/node": "*" + } + }, "@types/uuid": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", @@ -2521,6 +2572,17 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, + "exif-be-gone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/exif-be-gone/-/exif-be-gone-1.2.0.tgz", + "integrity": "sha512-FIfhEo2jJwXX94iLIONdxm2koKKarpwN6E8wMk8nfgTjRFZySMZRoWzWUvUEaTK+L6iAOzHpSNv4mgdL1JlLdQ==", + "requires": { + "@types/chai": "^4.2.12", + "@types/mocha": "^8.0.2", + "@types/node": "^14.0.27", + "@types/stream-buffers": "^3.0.3" + } + }, "express": { "version": "4.17.1", "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", 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) { |