import { download } from '@/api/platform/file/attachment'
import Utils from '@/utils/util'
import ActionUtils from '@/utils/action'

export function downloadFile(file) {
  download({
    attachmentId: file.id
  }).then(response => {
    if (!response) {
      return
    }
    ActionUtils.exportFile(
      response.data,
      file.fileName + (Utils.isNotEmpty(file.ext) ? '.' + file.ext : '')
    )
  }).catch(() => {
  })
}
