import request from '@/utils/request'

export function uploadPreparedData(key, file) {
  const data = new FormData()
  data.append('file', file)

  return request({
    url: `/api/upload-data/${key}`,
    method: 'post',
    data,
    timeout: 120000,
    headers: {
      'Content-Type': 'multipart/form-data',
      repeatSubmit: false
    }
  })
}

export function previewPreparedData(key, file) {
  const data = new FormData()
  data.append('file', file)

  return request({
    url: `/api/upload-data/${key}/preview`,
    method: 'post',
    data,
    timeout: 120000,
    headers: {
      'Content-Type': 'multipart/form-data',
      repeatSubmit: false
    }
  })
}

export function getSupportedUploadItems() {
  return request({
    url: '/api/upload-data/supported',
    method: 'get'
  })
}
