Skip to content

Commit

Permalink
Merge pull request #143 from webitel/fix/display-file-from-tts
Browse files Browse the repository at this point in the history
fix: display file from tts[WTEL-5171]
  • Loading branch information
Lera24 authored Oct 3, 2024
2 parents 736a627 + db29e82 commit 59a06be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/>
<span
class="chat-point-timeline-row-file__name"
@click="downloadFile({ id: file?.id, name: file?.name, type: file?.type })"
@click="downloadFile({ id: file?.id, name: file?.name, type: file?.type, url: file?.url })"
>{{ props.file.name }}</span>
</div>
</template>
Expand Down
19 changes: 13 additions & 6 deletions src/modules/contacts/modules/timeline/utils/downloadFile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
const downloadFile = ({ id, name, type }) => {
const downloadFile = ({ id, name, type, url }) => {

const a = document.createElement('a');
const token = localStorage.getItem('access-token');
let link = `${import.meta.env.VITE_API_URL}/storage/file/${id}/download?access_token=${token}`;

if (type.includes('source')) {
const source = type.match(/source=[^;]+/)[0];
link = `${link}&${source}`;
if(url) {
a.href = url;

} else {
let link = `${import.meta.env.VITE_API_URL}/storage/file/${id}/download?access_token=${token}`;

if (type.includes('source')) {
const source = type.match(/source=[^;]+/)[0];
link = `${link}&${source}`;
}
a.href = link;
}

a.href = link;
a.target = '_blank';
a.download = name;
a.click();
Expand Down

0 comments on commit 59a06be

Please sign in to comment.