upload: append file size if it hasn't been

This commit is contained in:
Alex Gleason 2024-11-07 13:10:15 -06:00
parent 95c7c4f87c
commit 6fae72b4cf
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -46,6 +46,7 @@ export async function uploadFile(
const x = tags.find(([key]) => key === 'x')?.[1]; const x = tags.find(([key]) => key === 'x')?.[1];
const m = tags.find(([key]) => key === 'm')?.[1]; const m = tags.find(([key]) => key === 'm')?.[1];
const dim = tags.find(([key]) => key === 'dim')?.[1]; const dim = tags.find(([key]) => key === 'dim')?.[1];
const size = tags.find(([key]) => key === 'size')?.[1];
const blurhash = tags.find(([key]) => key === 'blurhash')?.[1]; const blurhash = tags.find(([key]) => key === 'blurhash')?.[1];
if (!x) { if (!x) {
@ -57,6 +58,10 @@ export async function uploadFile(
tags.push(['m', file.type]); tags.push(['m', file.type]);
} }
if (!size) {
tags.push(['size', file.size.toString()]);
}
// If the uploader didn't already, try to get a blurhash and media dimensions. // If the uploader didn't already, try to get a blurhash and media dimensions.
// This requires `MEDIA_ANALYZE=true` to be configured because it comes with security tradeoffs. // This requires `MEDIA_ANALYZE=true` to be configured because it comes with security tradeoffs.
if (Conf.mediaAnalyze && (!blurhash || !dim)) { if (Conf.mediaAnalyze && (!blurhash || !dim)) {