downflux / FileManager
Defined in: packages/storage/FileManager.ts:20
Storage service for JSON results, buffers, and files on disk.
Storage is isolated because output handling needs path safety, filename normalization, resource type inference, stream sinks, JSON serialization, and post-processing for media containers. Keeping this here prevents providers and coordinators from duplicating filesystem rules.
new FileManager(
ffmpegEngine,progressManager):FileManager
Defined in: packages/storage/FileManager.ts:25
FileManager
createSink(
sinkInput):object
Defined in: packages/storage/FileManager.ts:36
Creates the output sink for a download.
Output mode, provider, identifier, and transcode options.
object
Writable stream and finalize callback for the selected output mode.
stream:
Writable
finalize: (
resolved,headers,isFmp4?) =>Promise<CreateSinkOutput>
Record<string, string>
boolean
Promise<CreateSinkOutput>
finalizeStream(
finalPath,tOptions?,isFmp4?,opts?):Promise<{path:string;filename:string;extension:string;mimeType:any; }>
Defined in: packages/storage/FileManager.ts:148
Finalizes a file after streaming completes.
string
Path of the streamed file.
Optional ffmpeg transcode options.
boolean
Whether the stream came from an fMP4 HLS playlist.
Resolved extension and MIME type hints.
string
string
Promise<{ path: string; filename: string; extension: string; mimeType: any; }>
Final path, filename, extension, and MIME type.
toJSON<
T,S>(result,directoryPath?):string
Defined in: packages/storage/FileManager.ts:176
Writes an execution result as JSON.
T
S extends ExecutionShape
ExecutionResult<T, S>
Execution result to serialize.
string = ...
Destination directory.
string
Path to the written JSON file.
getFileInfo(
url,prefix?):ResolvedFile
Defined in: packages/storage/FileManager.ts:200
Extracts filename and extension from URL.
string
URL to extract filename and extension from
string
Optional prefix to add to the filename
path undefined => fud_timestamp
sanitizeFilename(
name):string
Defined in: packages/storage/FileManager.ts:226
Sanitize filename by replacing invalid characters with underscores mostly for Windows OS which has a lot of reserved characters for filenames such as < > : " / \ | ? *
string
string
detectResourceType(
url,request):object
Defined in: packages/storage/FileManager.ts:269
Infers MIME type and extension for a media URL.
string
Media URL to inspect.
Provider request used for fallback decisions.
object
Detected or provider-default resource type.
mimeType:
string
extension:
AllowedExtension
deriveResolvedFile(
initial,finalUrl,headers,isFmp4?,prefix?):ResolvedFile
Defined in: packages/storage/FileManager.ts:307
Reconciles the initial file guess with the final response URL and headers.
Filename inferred before requesting the stream.
string
Final URL returned by the stream request.
Record<string, string>
Response headers.
boolean
Whether the media is fMP4 HLS.
string
Optional filename prefix.
Resolved filename and extension for the actual media.