iframe-fetch-client: encode body as base64 text (to make binary files work)

This commit is contained in:
Alex Gleason committed 2025-09-13 22:01:19 -05:00
1 parent fa34cade7a
commit 04f81a3375
7 files changed
+101 -17

No files matched your search

+18
View File
@@ -205,6 +205,24 @@ export class ProjectsManager {
}
}
async readFileBytes(projectId: string, filePath: string): Promise<Uint8Array> {
const fullPath = `${this.dir}/${projectId}/${filePath}`;
try {
const stat = await this.fs.stat(fullPath);
if (stat.isFile()) {
return await this.fs.readFile(fullPath);
} else {
throw new Error(`Path is not a file: ${filePath}`);
}
} catch (error) {
const fsError = error as NodeJS.ErrnoException;
if (fsError.code === 'ENOENT') {
throw new Error(`File not found: ${filePath}`);
}
throw error;
}
}
async writeFile(projectId: string, filePath: string, content: string): Promise<void> {
const fullPath = `${this.dir}/${projectId}/${filePath}`;
const dir = fullPath.split('/').slice(0, -1).join('/');