mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-02-04 06:51:44 +00:00
fix: use file as field name instead of chunk in cdi vmimage upload (#684)
Signed-off-by: Cooper Tseng <cooper.tseng@suse.com>
This commit is contained in:
parent
b1b1a31c04
commit
915559962a
@ -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
|
||||||
|
|||||||
@ -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 });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user