carnet panel2
This commit is contained in:
parent
9d232cc5cf
commit
8b158b5da5
@ -45,24 +45,30 @@ export async function GET(request: Request) {
|
|||||||
const normalizedBaseURL = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
|
const normalizedBaseURL = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
|
||||||
|
|
||||||
// Construct the full WebDAV URL
|
// Construct the full WebDAV URL
|
||||||
const webdavURL = `${normalizedBaseURL}/remote.php/dav/files/${credentials.username}/Private/${folder}`;
|
const webdavURL = `${normalizedBaseURL}/remote.php/dav`;
|
||||||
console.log('WebDAV URL:', webdavURL);
|
console.log('WebDAV base URL:', webdavURL);
|
||||||
|
|
||||||
const client = createClient({
|
const client = createClient(webdavURL, {
|
||||||
username: credentials.username,
|
username: credentials.username,
|
||||||
password: credentials.password,
|
password: credentials.password,
|
||||||
baseURL: normalizedBaseURL,
|
|
||||||
authType: 'basic',
|
authType: 'basic',
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// List files in the specified folder
|
// List files in the specified folder
|
||||||
const files = await client.getDirectoryContents(`/remote.php/dav/files/${credentials.username}/Private/${folder}`);
|
const path = `/files/${credentials.username}/Private/${folder}`;
|
||||||
console.log('Found files:', files.length);
|
console.log('Fetching contents from path:', path);
|
||||||
|
|
||||||
|
const files = await client.getDirectoryContents(path);
|
||||||
|
console.log('Raw files response:', JSON.stringify(files, null, 2));
|
||||||
|
|
||||||
// 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) => {
|
||||||
|
const isMarkdown = file.basename.endsWith('.md');
|
||||||
|
console.log(`File: ${file.basename}, isMarkdown: ${isMarkdown}`);
|
||||||
|
return isMarkdown;
|
||||||
|
})
|
||||||
.map((file: any) => ({
|
.map((file: any) => ({
|
||||||
id: file.filename,
|
id: file.filename,
|
||||||
title: file.basename.replace('.md', ''),
|
title: file.basename.replace('.md', ''),
|
||||||
@ -70,6 +76,7 @@ export async function GET(request: Request) {
|
|||||||
size: file.size,
|
size: file.size,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
console.log('Found markdown files:', markdownFiles.length);
|
||||||
return NextResponse.json(markdownFiles);
|
return NextResponse.json(markdownFiles);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error listing directory contents:', error);
|
console.error('Error listing directory contents:', error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user