mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-02-04 06:51:44 +00:00
(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:
parent
f411a0c0af
commit
b5e78018a5
@ -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
|
||||
|
||||
@ -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 });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user