From b5e78018a58849f7fe59f86fc5d0da345976c692 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 11:00:50 +0800 Subject: [PATCH] fix: use file as field name instead of chunk in cdi vmimage upload (#684) (#688) (cherry picked from commit 915559962a91802789750cec7549b61baea096e7) Signed-off-by: Cooper Tseng Co-authored-by: Kuan-Po Tseng --- pkg/harvester/l10n/en-us.yaml | 2 ++ .../models/harvesterhci.io.virtualmachineimage.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/harvester/l10n/en-us.yaml b/pkg/harvester/l10n/en-us.yaml index 937c2e3d..43cd7322 100644 --- a/pkg/harvester/l10n/en-us.yaml +++ b/pkg/harvester/l10n/en-us.yaml @@ -922,6 +922,8 @@ harvester: checksumTip: Validate the image using the SHA512 checksum, if specified. tooltip: imported: Created automatically by the vm-import-controller + errors: + unsupportedBackend: 'Unsupported backend type: {backend}' vmTemplate: label: Templates diff --git a/pkg/harvester/models/harvesterhci.io.virtualmachineimage.js b/pkg/harvester/models/harvesterhci.io.virtualmachineimage.js index 27f9b291..7414af70 100644 --- a/pkg/harvester/models/harvesterhci.io.virtualmachineimage.js +++ b/pkg/harvester/models/harvesterhci.io.virtualmachineimage.js @@ -318,8 +318,21 @@ export default class HciVmImage extends HarvesterResource { get uploadImage() { return async(file, opt = {}) => { const formData = new FormData(); + const backend = this.spec?.backend || 'backingimage'; + const backendFieldMap = { + cdi: 'file', + backingimage: 'chunk' + }; + const fieldName = backendFieldMap[backend]; - formData.append('chunk', file); + if (!fieldName) { + const error = this.t('harvester.image.errors.unsupportedBackend', { backend }); + + this.$ctx.commit('harvester-common/uploadError', { name: this.name, message: error }, { root: true }); + throw new Error(error); + } + + formData.append(fieldName, file); try { this.$ctx.commit('harvester-common/uploadStart', this.metadata.name, { root: true });