mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
Feature/v2/filehistory (#4370)
File History --------- Co-authored-by: Connor Yoh <[email protected]>
This commit is contained in:
@@ -8,11 +8,12 @@ export type ResponseHandler = (blob: Blob, originalFiles: File[]) => Promise<Fil
|
||||
* - If a tool-specific responseHandler is provided, it is used.
|
||||
* - If responseHeaders provided and contains Content-Disposition, uses that filename.
|
||||
* - Otherwise, create a single file using the filePrefix + original name.
|
||||
* - If filePrefix is empty, preserves the original filename.
|
||||
*/
|
||||
export async function processResponse(
|
||||
blob: Blob,
|
||||
originalFiles: File[],
|
||||
filePrefix: string,
|
||||
filePrefix?: string,
|
||||
responseHandler?: ResponseHandler,
|
||||
responseHeaders?: Record<string, any>
|
||||
): Promise<File[]> {
|
||||
@@ -36,7 +37,13 @@ export async function processResponse(
|
||||
|
||||
// Default behavior: use filePrefix + original name
|
||||
const original = originalFiles[0]?.name ?? 'result.pdf';
|
||||
const name = `${filePrefix}${original}`;
|
||||
// Only add prefix if it's not empty - this preserves original filenames for file history
|
||||
const name = filePrefix ? `${filePrefix}${original}` : original;
|
||||
const type = blob.type || 'application/octet-stream';
|
||||
return [new File([blob], name, { type })];
|
||||
|
||||
// File was modified by tool processing - set lastModified to current time
|
||||
return [new File([blob], name, {
|
||||
type,
|
||||
lastModified: Date.now()
|
||||
})];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user