fixed export of images
This commit is contained in:
parent
3e7a4f8983
commit
09e54033dd
4 changed files with 1230 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { env } from '$env/dynamic/private';
|
||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import type { RequestHandler } from './$types';
|
import type { RequestHandler } from './$types';
|
||||||
import {
|
import {
|
||||||
|
|
@ -27,11 +28,17 @@ export const GET: RequestHandler = async ({ locals }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch each image as base64
|
// Fetch each image as base64
|
||||||
|
// Inside Docker, stored PUBLIC_POCKETBASE_URL (http://localhost:8080) doesn't resolve
|
||||||
|
// from the app container, so we translate to the internal URL for fetching.
|
||||||
|
const publicBase = env.PUBLIC_POCKETBASE_URL || 'http://localhost:8080';
|
||||||
|
const internalBase = env.POCKETBASE_INTERNAL_URL || publicBase;
|
||||||
|
|
||||||
const images: Record<string, string> = {};
|
const images: Record<string, string> = {};
|
||||||
for (const url of allUrls) {
|
for (const url of allUrls) {
|
||||||
try {
|
try {
|
||||||
|
const fetchUrl = url.startsWith(publicBase) ? url.replace(publicBase, internalBase) : url;
|
||||||
const key = urlToKey(url);
|
const key = urlToKey(url);
|
||||||
images[key] = await fetchImageAsBase64(url);
|
images[key] = await fetchImageAsBase64(fetchUrl);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(`Could not fetch image: ${url}`, e);
|
console.warn(`Could not fetch image: ${url}`, e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
606
backups/cms-export-2026-06-05-001.json
Normal file
606
backups/cms-export-2026-06-05-001.json
Normal file
File diff suppressed because one or more lines are too long
616
backups/cms-export-2026-06-05-002.json
Normal file
616
backups/cms-export-2026-06-05-002.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue