(
data: Uint8Array<ArrayBufferLike>,
clientProvidedFilePath: string,
extension: SupportedExtensions,
)
| 786 | } |
| 787 | |
| 788 | async saveFile( |
| 789 | data: Uint8Array<ArrayBufferLike>, |
| 790 | clientProvidedFilePath: string, |
| 791 | extension: SupportedExtensions, |
| 792 | ): Promise<{filename: string}> { |
| 793 | await this.validatePath(clientProvidedFilePath); |
| 794 | try { |
| 795 | const filePath = ensureExtension( |
| 796 | path.resolve(clientProvidedFilePath), |
| 797 | extension, |
| 798 | ); |
| 799 | await fs.mkdir(path.dirname(filePath), {recursive: true}); |
| 800 | await fs.writeFile(filePath, data); |
| 801 | return {filename: filePath}; |
| 802 | } catch (err) { |
| 803 | this.logger?.(err); |
| 804 | throw new Error('Could not save a file', {cause: err}); |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | storeTraceRecording(result: TraceResult): void { |
| 809 | // Clear the trace results because we only consume the latest trace currently. |
no test coverage detected