feat(images): support uploading local ISO/vztmpl files to node storage
Some checks failed
Deploy to Production / Trigger production update (push) Has been cancelled
Backend Tests / pytest (Python 3.12) (push) Has been cancelled

Adds a local file upload path alongside the existing URL download flow:
a new /images/upload endpoint streams the file to a temp path and hands
it to a background worker that proxies it into Proxmox storage via the
upload API (requests-toolbelt handles the large multipart stream). Also
adds /images/resolve-filename to recover the real filename (Content-
Disposition) for URL-based downloads with opaque paths.

Raise nginx client_max_body_size and timeouts on both the frontend proxy
and the standalone nginx configs so multi-GB ISOs don't get cut off.
This commit is contained in:
markmorado
2026-07-24 06:17:46 +05:00
parent 8b4c8c3a30
commit 99d8ce750d
13 changed files with 533 additions and 52 deletions

View File

@@ -99,6 +99,50 @@ export function useDownloadImage(serverId: number) {
});
}
export interface ImageUploadRequest {
node: string;
storage: string;
content: 'iso' | 'vztmpl';
file: File;
filename?: string;
checksum?: string;
checksum_algorithm?: string;
}
// Загрузка локального файла (drag&drop) на ноду: multipart, без JSON.
export function useUploadImageFile(serverId: number) {
const qc = useQueryClient();
return useMutation({
mutationFn: (data: ImageUploadRequest) => {
const form = new FormData();
form.append('node', data.node);
form.append('storage', data.storage);
form.append('content', data.content);
if (data.filename) form.append('filename', data.filename);
if (data.checksum) form.append('checksum', data.checksum);
if (data.checksum_algorithm) form.append('checksum_algorithm', data.checksum_algorithm);
form.append('file', data.file);
return apiClient.postForm<{ task_id: number; status: string; name: string }>(
`/proxmox/api/${serverId}/images/upload`,
form,
);
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['all-tasks'] });
},
});
}
// Определить реальное имя файла по URL (Content-Disposition / хвост после редиректов).
export function useResolveFilename() {
return useMutation({
mutationFn: (url: string) =>
apiClient.get<{ filename: string }>(
`/proxmox/api/images/resolve-filename?url=${encodeURIComponent(url)}`,
),
});
}
// ── Custom mirrors (admin) ───────────────────────────────────────────────────
export function useImageMirrors(enabled = true) {