Fix Eror Code get_images.ts (1)

This commit is contained in:
2026-01-30 17:15:39 +08:00
parent f0425cfc47
commit 8afbaabd91

View File

@@ -31,12 +31,18 @@ async function getDirItems(): Promise<DirItem[]> {
async function getDownloadUrl(filePath: string): Promise<string> { async function getDownloadUrl(filePath: string): Promise<string> {
const res = await fetch( const res = await fetch(
`${BASE_URL}/repos/${REPO_ID}/file/?p=${encodeURIComponent(filePath)}`, `${BASE_URL}/repos/${REPO_ID}/file/?p=${encodeURIComponent(filePath)}&reuse=1`,
{ headers }, { headers },
); );
if (!res.ok) { if (!res.ok) {
throw new Error(`Failed get file url: ${res.statusText}`); const text = await res.text();
console.error("Seafile error:", {
status: res.status,
body: text,
url: res.url,
});
throw new Error(`Failed get file url`);
} }
const data = await res.json(); const data = await res.json();
@@ -66,10 +72,3 @@ export async function getAllDownloadUrls() {
return results; return results;
} }
if (import.meta.main) {
console.log("get data ...")
getAllDownloadUrls().then((res) => {
console.log(res);
});
}