@putkoff/abstract-securefiles 0.0.45 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FileHandlers/FileTable/imports.d.ts +1 -1
- package/dist/FileHandlers/imports.d.ts +1 -1
- package/dist/file_utils/imports.d.ts +1 -1
- package/dist/file_utils/src/delete_utils/imports.d.ts +1 -1
- package/dist/file_utils/src/download_utils/imports.d.ts +1 -1
- package/dist/file_utils/src/download_utils/src/download_select.d.ts +1 -1
- package/dist/file_utils/src/imports.d.ts +1 -1
- package/dist/file_utils/src/list_utils/imports.d.ts +0 -1
- package/dist/file_utils/src/share_utils/imports.d.ts +0 -1
- package/dist/hooks/imports.d.ts +1 -1
- package/dist/hooks/useFiles/imports.d.ts +1 -1
- package/dist/imports.d.ts +0 -1
- package/dist/index.cjs +114 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +115 -108
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/FileHandlers/FileTable/imports.ts +0 -1
- package/src/FileHandlers/imports.ts +0 -1
- package/src/file_utils/imports.ts +1 -1
- package/src/file_utils/src/delete_utils/imports.ts +1 -1
- package/src/file_utils/src/download_utils/imports.ts +1 -1
- package/src/file_utils/src/download_utils/src/download_select.ts +18 -13
- package/src/file_utils/src/imports.ts +1 -1
- package/src/file_utils/src/list_utils/imports.ts +1 -1
- package/src/file_utils/src/share_utils/imports.ts +0 -1
- package/src/hooks/imports.ts +1 -1
- package/src/hooks/useFiles/imports.ts +1 -1
- package/src/imports.ts +2 -3
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {triggerDownload} from './trigger_download';
|
|
3
|
-
|
|
4
|
-
const token: string = requireToken();
|
|
5
|
-
const body = item
|
|
6
|
-
const headers = {
|
|
7
|
-
Authorization: `Bearer ${token}`,
|
|
8
|
-
Accept: "application/octet-stream",
|
|
9
|
-
"Content-Type": "application/json"
|
|
10
|
-
}
|
|
11
|
-
const blob = await secureFetchIt( "download", body, "POST", headers, true, true) as Blob;
|
|
1
|
+
import type { FileItem } from './../imports';
|
|
2
|
+
import { triggerDownload } from './trigger_download';
|
|
3
|
+
import { SECURE_FILES_API_BASE } from './../../cookieFetch';
|
|
12
4
|
|
|
5
|
+
export async function downloadSelect(item: FileItem): Promise<void> {
|
|
6
|
+
const res = await fetch(`${SECURE_FILES_API_BASE}/download`, {
|
|
7
|
+
method: "POST",
|
|
8
|
+
credentials: "include",
|
|
9
|
+
headers: {
|
|
10
|
+
"Content-Type": "application/json",
|
|
11
|
+
Accept: "application/octet-stream",
|
|
12
|
+
},
|
|
13
|
+
body: JSON.stringify(item),
|
|
14
|
+
});
|
|
13
15
|
|
|
16
|
+
if (res.status === 401) throw new Error("Not authenticated – please log in.");
|
|
17
|
+
if (!res.ok) throw new Error(`Download failed: HTTP ${res.status}`);
|
|
14
18
|
|
|
19
|
+
const blob = await res.blob();
|
|
15
20
|
if (!blob || blob.size === 0) {
|
|
16
|
-
throw new Error(`Received empty file data for
|
|
21
|
+
throw new Error(`Received empty file data for "${item.filename}"`);
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
triggerDownload(blob, item.filename);
|
|
20
|
-
}
|
|
25
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
export type { FileItem,ApiRow } from './../imports';
|
package/src/hooks/imports.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { FileItem,ApiRow } from './../imports';
|
|
2
|
-
export {
|
|
2
|
+
export { alertit,useCallback,isLoggedIn} from './../imports';
|
|
3
3
|
export {toggleShare,removeFile,listFiles,downloadFile} from './../file_utils'
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
2
|
export type { FileItem,ApiRow } from './../imports';
|
|
3
|
-
export {
|
|
3
|
+
export { alertit,toggleShare,removeFile,listFiles,useCallback,downloadFile,isLoggedIn } from './../imports';
|
package/src/imports.ts
CHANGED
|
@@ -11,9 +11,8 @@ export {
|
|
|
11
11
|
stripPrefixes,
|
|
12
12
|
make_path
|
|
13
13
|
} from "@putkoff/abstract-utilities";
|
|
14
|
-
export {
|
|
14
|
+
export {
|
|
15
15
|
Button,
|
|
16
16
|
Checkbox,
|
|
17
17
|
Input,
|
|
18
|
-
Spinner} from './UI';
|
|
19
|
-
export { secureFetchIt, fetchSharePatch } from "@putkoff/abstract-apis";
|
|
18
|
+
Spinner} from './UI';
|