<%_ if (position === 'import') { _%>
  <%_ if (clientTheme === 'vben' && clientFramework === 'vue') { _%>
import { UploadFileParams } from '@/types/axios';
import { AxiosProgressEvent } from 'axios';
  <%_ } _%>
<%_ } _%>
<%_ if (position === 'method') { _%>
  <%_ if (clientTheme === 'vben' && clientFramework === 'vue') { _%>
  create(uploadImage: IUploadImage, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void, success?) {
    const params: UploadFileParams = <UploadFileParams>{};
    params.name = 'image';
    params.file = uploadImage.file as File;
    if (uploadImage.filename) {
      params.filename = uploadImage.filename;
    } else {
      params.filename = uploadImage.file?.name || 'noFileName';
    }
    const newUploadImage = { ...uploadImage };
    delete newUploadImage.file;
    params.data = { uploadImageDTO: _pickBy(newUploadImage, value => !!value) };
    return defHttp.uploadFile<IUploadImage>(
      {
        url: `${apiUrl}`,
        onUploadProgress,
      },
      params,
      { isReturnResponse: true, success },
    );
  },
  uploadImageUrl: apiUrl,
  <%_ } _%>
  <%_ if (clientTheme === 'antd' && clientFramework === 'react') { _%>

export async function uploadImage(params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void) {
  return request<IUploadImage>(`${apiUrl}`, { method: 'POST', requestType: 'form', data: params});
}
  <%_ } _%>
<%_ } _%>
