feat(uploads): accept 15 MB / 8000px and every standard image format
- API ceiling 8 MB -> 15 MB, sharp limitInputPixels 64 MP (8000x8000) - accept AVIF, BMP, TIFF, HEIC/HEIF, JXL alongside JPEG/PNG/WebP/GIF/SVG/PDF; fall back to the file extension when the browser sends an empty or octet-stream type - convert formats browsers cannot paint (TIFF, HEIC, JXL) to WebP on upload - pre-warm 200/400/600/1600 variants so card thumbnails never wait on a render - nginx: client_max_body_size 20m, proxy_read_timeout 180s (the 1m default rejected every real photo with a bare 413, and a slow 8000px render became a 504 that left the card thumbnail broken while /uploads worked) - gallery tile falls back to the original file if a variant fails Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
072344f85e
commit
387222851c
@@ -5,6 +5,16 @@ server {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Uploads are capped at 15 MB by the API; nginx's 1 MB default would reject
|
||||
# any real photo with a bare 413 before the request ever reached it.
|
||||
client_max_body_size 20m;
|
||||
|
||||
# The first request for a given /api/img width renders it on demand; an
|
||||
# 8000px source can take a while on a small VPS, and nginx's 60s default
|
||||
# turned that into a 504 — a card thumbnail that stayed broken until the
|
||||
# variant finished, while the original (/uploads) opened fine.
|
||||
proxy_read_timeout 180s;
|
||||
|
||||
# Docker's embedded DNS. Without re-resolving at request time, nginx caches the
|
||||
# api container's IP from startup and keeps returning 502 ("no live upstreams")
|
||||
# after the api container restarts with a new IP.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<input
|
||||
ref="input"
|
||||
type="file"
|
||||
accept="image/jpeg,image/png,image/webp,application/pdf"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/avif,image/bmp,image/tiff,image/heic,image/heif,image/svg+xml,application/pdf"
|
||||
class="siu__input"
|
||||
@change="onPick"
|
||||
/>
|
||||
@@ -58,9 +58,12 @@ const error = ref<string | null>(null)
|
||||
const fileId = ref<string | null>(null)
|
||||
const preview = ref<string | null>(null)
|
||||
|
||||
/** 8 MB — the same ceiling the API enforces, checked here for a fast message. */
|
||||
const MAX_BYTES = 8 * 1024 * 1024
|
||||
const ACCEPTED = /^(image\/(jpeg|png|webp)|application\/pdf)$/
|
||||
/** 15 MB — the same ceiling the API enforces, checked here for a fast message. */
|
||||
const MAX_BYTES = 15 * 1024 * 1024
|
||||
const ACCEPTED =
|
||||
/^(image\/(jpeg|jpg|pjpeg|png|apng|gif|webp|svg\+xml|avif|bmp|x-ms-bmp|tiff|heic|heif|jxl)|application\/pdf)$/
|
||||
/** Same list by extension, for files the browser reports with an empty type. */
|
||||
const ACCEPTED_EXT = /\.(jpe?g|png|apng|gif|webp|svg|avif|bmp|tiff?|heic|heif|jxl|pdf)$/i
|
||||
|
||||
function failureText(e: unknown): string {
|
||||
if (e instanceof UnauthorizedError) return 'برای بارگذاری، دوباره وارد حساب شوید'
|
||||
@@ -79,7 +82,7 @@ async function onPick(event: Event) {
|
||||
|
||||
error.value = null
|
||||
|
||||
if (!ACCEPTED.test(file.type)) {
|
||||
if (!(file.type ? ACCEPTED.test(file.type) : ACCEPTED_EXT.test(file.name))) {
|
||||
error.value = 'این نوع فایل پشتیبانی نمیشود؛ فقط تصویر JPG، PNG، WebP یا PDF'
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user