Enhancment: Formatted filename for single document downloads (#12095)

---------

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
Jan Kleine
2026-02-26 19:06:47 +01:00
committed by GitHub
parent 5e1202a416
commit c86ebc0260
7 changed files with 107 additions and 18 deletions
@@ -272,10 +272,10 @@ describe(`DocumentService`, () => {
expect(url).toEqual(
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/download/?version=123`
)
url = service.getDownloadUrl(documents[0].id, true, 123)
expect(url).toEqual(
`${environment.apiBaseUrl}${endpoint}/${documents[0].id}/download/?original=true&version=123`
)
url = service.getDownloadUrl(documents[0].id, true, 123, true)
expect(url).toContain('original=true')
expect(url).toContain('version=123')
expect(url).toContain('follow_formatting=true')
})
it('should pass optional get params for version and fields', () => {
@@ -202,7 +202,8 @@ export class DocumentService extends AbstractPaperlessService<Document> {
getDownloadUrl(
id: number,
original: boolean = false,
versionID: number = null
versionID: number = null,
followFormatting: boolean = false
): string {
let url = new URL(this.getResourceUrl(id, 'download'))
if (original) {
@@ -211,6 +212,9 @@ export class DocumentService extends AbstractPaperlessService<Document> {
if (versionID) {
url.searchParams.append('version', versionID.toString())
}
if (followFormatting) {
url.searchParams.append('follow_formatting', 'true')
}
return url.toString()
}