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 <cooper.tseng@suse.com>
Co-authored-by: Kuan-Po Tseng <brandboat@gmail.com>
This commit is contained in:
mergify[bot] 2026-01-20 11:00:50 +08:00 committed by GitHub
parent f411a0c0af
commit b5e78018a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -922,6 +922,8 @@ harvester:
checksumTip: Validate the image using the SHA512 checksum, if specified. checksumTip: Validate the image using the SHA512 checksum, if specified.
tooltip: tooltip:
imported: Created automatically by the vm-import-controller imported: Created automatically by the vm-import-controller
errors:
unsupportedBackend: 'Unsupported backend type: {backend}'
vmTemplate: vmTemplate:
label: Templates label: Templates

View File

@ -318,8 +318,21 @@ export default class HciVmImage extends HarvesterResource {
get uploadImage() { get uploadImage() {
return async(file, opt = {}) => { return async(file, opt = {}) => {
const formData = new FormData(); 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 { try {
this.$ctx.commit('harvester-common/uploadStart', this.metadata.name, { root: true }); this.$ctx.commit('harvester-common/uploadStart', this.metadata.name, { root: true });