Skip to content

Commit 76af245

Browse files
committed
Basic support for saving a file
1 parent c95f4a6 commit 76af245

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/drive.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,22 @@ export class FileSystemDrive implements Contents.IDrive {
123123
throw new Error('Method not implemented.');
124124
}
125125

126-
save(
126+
async save(
127127
localPath: string,
128128
options?: Partial<Contents.IModel>
129129
): Promise<Contents.IModel> {
130-
throw new Error('Method not implemented.');
130+
const root = this._rootHandle;
131+
132+
if (!root) {
133+
throw new Error('No root file handle');
134+
}
135+
136+
const handle = await root.getFileHandle(localPath);
137+
const writable = await handle.createWritable({});
138+
const content = options?.content;
139+
await writable.write(content);
140+
await writable.close();
141+
return this.get(localPath);
131142
}
132143

133144
copy(localPath: string, toLocalDir: string): Promise<Contents.IModel> {

0 commit comments

Comments
 (0)