CF2-8: HotFix. Исправлено преобразование полученного массива байтов в файл

This commit is contained in:
KharchenkoVV 2021-06-07 18:12:21 +05:00
parent 6a2fa499df
commit a89c5200d7

View File

@ -37,6 +37,11 @@ const imgPaths = {
'.las': '/images/las.png' '.las': '/images/las.png'
} }
const contentTypes = {
'.pdf': 'application/pdf',
'.las': 'application/octet-stream'
}
// Экспорт рендера // Экспорт рендера
export default function Report(props) { export default function Report(props) {
@ -80,8 +85,8 @@ export default function Report(props) {
<br /> <br />
<span> { progressData.operation } </span> <span> { progressData.operation } </span>
<br /> <br />
<a onClick={event => {getReportFile(event, progressData.reportName)}} <a onClick={event => getReportFile(event, progressData.reportName)}
download={progressData.reportName}> download>
{ progressData.reportName } { progressData.reportName }
</a> </a>
</> </>
@ -91,8 +96,9 @@ export default function Report(props) {
const getReportFile = async (event, reportFileName) => { const getReportFile = async (event, reportFileName) => {
try { try {
const element = event.target const element = event.target
let reportFile = await ReportService.getReport(wellId, reportFileName) let bytesArray = await ReportService.getReport(wellId, reportFileName)
let reportUrl = URL.createObjectURL(reportFile) const contentType = contentTypes[reportFileName.slice(-4)]
let reportUrl = URL.createObjectURL(new File(bytesArray, {type: contentType}))
element.href = reportUrl element.href = reportUrl
} catch (error) { } catch (error) {
notify(`Не удалось скачать отчет по скважине (${wellId}) c notify(`Не удалось скачать отчет по скважине (${wellId}) c
@ -120,7 +126,7 @@ export default function Report(props) {
duration: 0 duration: 0
}); });
if (progressData.reportName.length) if (progressData.reportName?.length)
unSubscribeReportHub() unSubscribeReportHub()
} }
} }