1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 20:52:42 +01:00

added removal of metadata

includes all posted assets
This commit is contained in:
xnacly 2021-08-10 16:51:45 +02:00
parent a349841841
commit e8052ce7fc
3 changed files with 69 additions and 1 deletions

62
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

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