feat(backup): download the full backup as ZIP
GET /export?format=zip streams the JSON backup compressed (plain JSON stays the API default). The MindSift import recognises the backup ZIP next to the plain JSON and the Markdown archive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1601a6a2d5
commit
1df32ece92
7 files changed
+122
-25
No files matched your search
+14
-7
@@ -135,6 +135,14 @@ export const setCurrentSharingMode = (mode: SharingMode) => {
|
||||
};
|
||||
export const isSharingDisabled = () => currentSharingMode === 'private';
|
||||
|
||||
// Authenticated binary download (archives); no JSON parsing and no request timeout
|
||||
async function downloadBlob(path: string): Promise<Blob> {
|
||||
const token = getToken();
|
||||
const res = await fetch(path, { headers: token ? { Authorization: `Bearer ${token}` } : {}, cache: 'no-store' });
|
||||
if (!res.ok) throw new Error(`Download fehlgeschlagen (HTTP ${res.status})`);
|
||||
return res.blob();
|
||||
}
|
||||
|
||||
export const api = {
|
||||
// --- AUTH, FIRST-BOOT SETUP & SETTINGS ---
|
||||
async getAuthStatus(): Promise<AuthStatus> {
|
||||
@@ -1093,15 +1101,14 @@ export const api = {
|
||||
return data as ImportSummary;
|
||||
},
|
||||
|
||||
// Full backup (all data as JSON) packed into a ZIP; restorable via importData('mindsift', …)
|
||||
async exportBackupZip(): Promise<Blob> {
|
||||
return downloadBlob('/api/v1/export?format=zip');
|
||||
},
|
||||
|
||||
// Obsidian-compatible ZIP of the workspace; binary and possibly large, so no JSON helper and no timeout
|
||||
async exportMarkdownVault(): Promise<Blob> {
|
||||
const token = getToken();
|
||||
const res = await fetch('/api/v1/export/markdown', {
|
||||
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
||||
cache: 'no-store',
|
||||
});
|
||||
if (!res.ok) throw new Error(`Export fehlgeschlagen (HTTP ${res.status})`);
|
||||
return res.blob();
|
||||
return downloadBlob('/api/v1/export/markdown');
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user