feat: Google Drive restore endpoints (Faz 3)

GET /api/google-drive/backup-files: kullanıcının senkronize
edilmiş dosyalarının listesi (PRD §28 "N dosya bulundu"). GET
/download: bir dosyayı Drive'dan proxy'leyip ham baytları döner —
istenen drive_file_id'nin gerçekten bu kullanıcıya ait olduğu
önce doğrulanıyor (PRD §39, başka kullanıcının backup'ı sızmasın).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
mstfyldz
2026-08-10 04:24:56 +03:00
co-authored by Claude Sonnet 5
parent 313d5b72ef
commit ce6fa9deae
3 changed files with 77 additions and 1 deletions
+15
View File
@@ -216,3 +216,18 @@ export async function uploadFileResumable(accessToken: string, params: UploadPar
}
return data;
}
// Faz 3 — Restore: bir dosyanın ham baytlarını Drive'dan indirir. Electron'un
// Google credential'ı hiç olmadığı için (upload'ta olduğu gibi) bu da backend
// üzerinden proxy'leniyor — çağıran taraf (googleDrive.controller.ts) fileId'nin
// gerçekten bu kullanıcıya ait olduğunu ÖNCE doğrulamalı.
export async function downloadFile(accessToken: string, fileId: string): Promise<Buffer> {
const res = await fetch(`${DRIVE_API_URL}/files/${fileId}?alt=media`, {
headers: { Authorization: `Bearer ${accessToken}` },
});
if (!res.ok) {
throw new Error(`Google Drive dosyası indirilemedi (HTTP ${res.status}).`);
}
const arrayBuffer = await res.arrayBuffer();
return Buffer.from(arrayBuffer);
}