| | |
| | | import { message } from 'ant-design-vue' |
| | | import request, { IPage, IWorkspaceResponse } from '/@/api/http/request' |
| | | const HTTP_PREFIX = '/media/api/v1' |
| | | |
| | |
| | | return result.data |
| | | } |
| | | // Download Media File |
| | | export const downloadMediaFile = async function (workspaceId: string, fingerprint: string): Promise<any> { |
| | | const url = `${HTTP_PREFIX}/files/${workspaceId}/file/${fingerprint}/url` |
| | | export const downloadMediaFile = async function (workspaceId: string, fileId: string): Promise<any> { |
| | | const url = `${HTTP_PREFIX}/files/${workspaceId}/file/${fileId}/url` |
| | | const result = await request.get(url, { responseType: 'blob' }) |
| | | if (result.data.code) { |
| | | if (result.data.type === 'application/json') { |
| | | const reader = new FileReader() |
| | | reader.onload = function (e) { |
| | | let text = reader.result as string |
| | | const result = JSON.parse(text) |
| | | message.error(result.message) |
| | | } |
| | | reader.readAsText(result.data, 'utf-8') |
| | | return |
| | | } else { |
| | | return result.data |
| | | } |
| | | return result |
| | | } |