add thumbnail generation
This commit is contained in:
@@ -18,6 +18,10 @@ function fileApiUrl(libraryId: string, relativePath: string): string {
|
||||
return `/api/file?libraryId=${encodeURIComponent(libraryId)}&path=${encodeURIComponent(relativePath)}`
|
||||
}
|
||||
|
||||
function thumbnailApiUrl(libraryId: string, relativePath: string): string {
|
||||
return `/api/thumbnail?libraryId=${encodeURIComponent(libraryId)}&path=${encodeURIComponent(relativePath)}`
|
||||
}
|
||||
|
||||
export function scanDirectory(
|
||||
libraryRoot: string,
|
||||
libraryId: string,
|
||||
@@ -43,17 +47,20 @@ export function scanDirectory(
|
||||
type: 'directory',
|
||||
mediaType: null,
|
||||
url: null,
|
||||
thumbnailUrl: null,
|
||||
}
|
||||
}
|
||||
|
||||
const relPath = subpath ? path.join(subpath, d.name) : d.name
|
||||
const mediaType = getMediaType(d.name)
|
||||
const hasThumbnail = mediaType === 'image' || mediaType === 'video'
|
||||
|
||||
return {
|
||||
name: d.name,
|
||||
type: 'file',
|
||||
mediaType,
|
||||
url: fileApiUrl(libraryId, relPath),
|
||||
thumbnailUrl: hasThumbnail ? thumbnailApiUrl(libraryId, relPath) : null,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user