Skip to content

Commit d1db369

Browse files
save file
1 parent d0fd99b commit d1db369

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

utils/misc/nodejs-terminal/html/webcontainer-fs/webcontainer-fs.html

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,15 @@
178178
btn.save = async function(){
179179

180180
var blob = await source();
181+
var buf = await blob.arrayBuffer();
182+
var uint8 = new Uint8Array(buf);
181183

182-
var abs = filenav.cur.path+filenav.cur.name'
183-
184-
console.json(filenav.cur);
184+
var name = filenav.cur.name;
185+
var abs = filenav.cur.path+name;
186+
await webcontainer.fs.writeFile(abs,uint8);
185187

188+
var file = newfile({name,abs});
189+
complete.save(file);
186190

187191
}//save
188192

@@ -198,6 +202,21 @@
198202
}//ok
199203

200204

205+
//:
206+
207+
208+
function newfile({name,abs}){
209+
210+
var file = {};
211+
file.type = filetype;
212+
file.name = name;
213+
file.title = abs;
214+
file.icon = icon.src;
215+
file.abs = abs;
216+
return file;
217+
218+
}//newfile
219+
201220
//:
202221

203222

@@ -237,6 +256,7 @@
237256
//console.log(dirs);
238257
//console.log(files);
239258
filenav.display(path,dirs,files);
259+
240260
return false;
241261

242262
}//read

0 commit comments

Comments
 (0)