win32.run
AppGithub
  • Introduction
  • Acknowledgements
  • Files Transfer
  • Developers
    • Run, build & deploy
    • Spaghetti Code
      • Code Structure
      • System Variables
      • Working with Files
      • Open a program with a file
    • 3rd-party apps
      • Pick Files
      • Save File As
      • Get File
      • Save File
Powered by GitBook
On this page
  • Params
  • Return
  • Example
  1. Developers
  2. 3rd-party apps

Save File As

PreviousPick FilesNextGet File

Last updated 2 years ago

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

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);
Mozilla Docs