mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-12 23:15:09 +00:00
Enhancment: Formatted filename for single document downloads (#12095)
--------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user