Save File As

Save a file to win32.run through File Saving Dialog

await win32.save_file_as(file, types)

Params

file

File

Content of the file you want to save to win32. A File object. See Mozilla Docs

types

[Object]

win32.run allows users to save a file as different mimetypes. For example: text can be save as regular .txt plain text (text/plain) or .html webpage (text/html)

types = [
     {desc: 'Plain Text', mime: 'text/plain', ext: '.txt'},
     {desc: 'Webpage', mime: 'text/html', ext: '.html'}
]

Return

Promise<String>

Promise that resolves with id of the saved file, which can be used to retrieve the file later without invoking the Files Picker dialog.

Example

let text_content = '<h1>This is a heading of a webpage</h1>';
let file = new File([text_content], '_'); 
let types = [
     {desc: 'Plain Text', mime: 'text/plain', ext: '.txt'},
     {desc: 'Webpage', mime: 'text/html', ext: '.html'}
];
let id = await win32.save_file_as(file, types);

Last updated