finnow/web-app/src/api/attachment.ts

28 lines
684 B
TypeScript

import type { RouteLocation } from 'vue-router'
import { ApiClient } from './base'
import { getSelectedProfile } from './profile'
export interface Attachment {
id: number
uploadedAt: string
filename: string
contentType: string
size: number
}
export class AttachmentApiClient extends ApiClient {
readonly profileName: string
constructor(route: RouteLocation) {
super()
this.profileName = getSelectedProfile(route)
}
downloadAttachment(attachmentId: number, token: string) {
const url =
import.meta.env.VITE_API_BASE_URL +
`/profiles/${this.profileName}/attachments/${attachmentId}/download?t=${token}`
window.open(url, '_blank')
}
}