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 });