瀏覽代碼

download file

FE_dev
Dzenis Hadzifejzovic 2 年之前
父節點
當前提交
9ed29742b1
共有 1 個文件被更改,包括 23 次插入16 次删除
  1. 23
    16
      src/pages/FilesPage/FilesViewPage.js

+ 23
- 16
src/pages/FilesPage/FilesViewPage.js 查看文件



const deleteFileHandler = (stream_id) => { const deleteFileHandler = (stream_id) => {
dispatch(deleteFileReq({ id: stream_id })); dispatch(deleteFileReq({ id: stream_id }));
console.log(stream_id)
console.log(file.fileStream)
if(file !== null && stream_id === file.streamId){
setFile(null)
if (file !== null && stream_id === file.streamId) {
setFile(null);
} }
}; };


console.log(e, "error in file-viewer"); console.log(e, "error in file-viewer");
}; };


const displayFile = (fileStream,streamId) => {
setFile({fileStream,streamId});
const displayFile = (fileStream, streamId) => {
setFile({ fileStream, streamId });
}; };
return isLoading ? ( return isLoading ? (
<div> <div>
<div className="l-t-rectangle"></div> <div className="l-t-rectangle"></div>
<th>Tip dokumenta</th> <th>Tip dokumenta</th>
{file === null ? <th>Veličina dokumenta</th> : ""} {file === null ? <th>Veličina dokumenta</th> : ""}
<th>Obrisi dokument</th> <th>Obrisi dokument</th>
<th>Preuzmi dokument</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr <tr
key={index} key={index}
className="secondaryRow" className="secondaryRow"
onClick={() => displayFile(n.file_stream,n.stream_id)}
onClick={() => displayFile(n.file_stream, n.stream_id)}
> >
<td className="docs-name">{n.fileName}</td> <td className="docs-name">{n.fileName}</td>
<td className="docs-name">{n.title}</td> <td className="docs-name">{n.title}</td>
/> />
</IconButton> </IconButton>
</td> </td>
<td>
<div onClick={stopPropagation}>
<a
className="applicant-cv-button"
style={{
width: "100px",
height: "40px",
padding: 8,
}}
download={n.title}
href={`data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,${n.file_stream}`}
>
{t("common.download")}
</a>
</div>
</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</div> </div>
)} )}
</div> </div>
{/* <a
className="applicant-cv-button"
download={"Proba2.docx"}
href={`data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,${file2}`}
title="Download pdf document"
>
{t("common.download")} file
</a> */}
<Pagination <Pagination
// size={matches ? "small" : "medium"} // size={matches ? "small" : "medium"}
size={"small"} size={"small"}

Loading…
取消
儲存