Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1x 1x | import { httpClient } from '@/shared/lib'
import { ACCOUNTING_OBJECTS_EXPORT_TARGET } from '@/entities/accounting-object'
import { FileModelWithPrivate } from '@/shared/@types'
import { ulid } from 'ulid'
import { EXCEL_ACCEPT } from '@/shared/config'
export const uploadMeasureFile = async (filters?: Record<string, unknown>) => {
const response = await httpClient<Blob>({
url: ACCOUNTING_OBJECTS_EXPORT_TARGET,
responseType: 'blob',
headers: {
Accept: EXCEL_ACCEPT,
},
params: filters,
}).then(res => {
return res.data
})
const uploadedFile = new File([response], `${new Date().toTimeString()}.xlsx`, {
type: response.type,
lastModified: new Date().getTime(),
})
const formData = new FormData()
formData.append('file', uploadedFile)
formData.append('originalName', `${new Date().toTimeString()}.xlsx`)
formData.append('id', ulid())
const res = await httpClient<FileModelWithPrivate, FormData>({
url: '/files',
data: formData,
method: 'POST',
})
return res
}
|