carnet panel2
This commit is contained in:
parent
e64a54c929
commit
947d3f048f
@ -47,28 +47,34 @@ export async function GET(request: Request) {
|
|||||||
const client = createClient({
|
const client = createClient({
|
||||||
username: credentials.username,
|
username: credentials.username,
|
||||||
password: credentials.password,
|
password: credentials.password,
|
||||||
baseURL: normalizedBaseURL,
|
baseURL: `${normalizedBaseURL}/remote.php/dav/files/${credentials.username}/Private`,
|
||||||
|
authType: 'basic',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Construct the folder path with leading slash
|
// Construct the folder path without leading slash
|
||||||
const folderPath = `/remote.php/dav/files/${credentials.username}/Private/${folder}`;
|
const folderPath = folder;
|
||||||
console.log('Full folder path:', folderPath);
|
console.log('Full folder path:', folderPath);
|
||||||
|
|
||||||
// List files in the specified folder
|
try {
|
||||||
const files = await client.getDirectoryContents(folderPath);
|
// List files in the specified folder
|
||||||
console.log('Found files:', files.length);
|
const files = await client.getDirectoryContents(folderPath);
|
||||||
|
console.log('Found files:', files.length);
|
||||||
|
|
||||||
// Filter for .md files and format the response
|
// Filter for .md files and format the response
|
||||||
const markdownFiles = files
|
const markdownFiles = files
|
||||||
.filter((file: any) => file.basename.endsWith('.md'))
|
.filter((file: any) => file.basename.endsWith('.md'))
|
||||||
.map((file: any) => ({
|
.map((file: any) => ({
|
||||||
id: file.filename,
|
id: file.filename,
|
||||||
title: file.basename.replace('.md', ''),
|
title: file.basename.replace('.md', ''),
|
||||||
lastModified: new Date(file.lastmod).toISOString(),
|
lastModified: new Date(file.lastmod).toISOString(),
|
||||||
size: file.size,
|
size: file.size,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return NextResponse.json(markdownFiles);
|
return NextResponse.json(markdownFiles);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error listing directory contents:', error);
|
||||||
|
return NextResponse.json({ error: 'Failed to list directory contents' }, { status: 500 });
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching files:', error);
|
console.error('Error fetching files:', error);
|
||||||
return NextResponse.json({ error: 'Failed to fetch files' }, { status: 500 });
|
return NextResponse.json({ error: 'Failed to fetch files' }, { status: 500 });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user