(folder, file, sourceId = '')
| 82 | } |
| 83 | |
| 84 | async function createAuthFileLink(folder, file, sourceId = '') { |
| 85 | const resp = await fetch(withBase('/api/file/createAuthFileLink.php'), { |
| 86 | method: 'POST', |
| 87 | credentials: 'include', |
| 88 | headers: { |
| 89 | 'Content-Type': 'application/json', |
| 90 | 'X-CSRF-Token': window.csrfToken || '', |
| 91 | 'Accept': 'application/json', |
| 92 | }, |
| 93 | body: JSON.stringify({ |
| 94 | folder, |
| 95 | file, |
| 96 | sourceId: String(sourceId || '').trim(), |
| 97 | }), |
| 98 | }); |
| 99 | |
| 100 | const data = await resp.json().catch(() => ({})); |
| 101 | if (!resp.ok || !data || data.ok !== true) { |
| 102 | throw new Error((data && (data.error || data.message)) || `HTTP ${resp.status}`); |
| 103 | } |
| 104 | return data; |
| 105 | } |
| 106 | |
| 107 | export async function openFileLinkModal(fileObj, folder) { |
| 108 | const fileName = String(fileObj?.name || '').trim(); |
no test coverage detected