WebExeBuilder Documentation

download

Category: File Operations

Namespace: web.files.download

Description

Save base64-encoded data to a file with optional user dialog. This API is designed for saving data that's already in memory (generated content, exports, or base64-encoded data).

⚠️ IMPORTANT: This API does NOT download from URLs directly. To download from a URL, use web.files.downloadFromUrl() instead.

Syntax

const result = await web.files.download({
    data: string,
    filename: string,
    path: string,
    overwrite: boolean
});

Parameters

  • data (required) - Base64-encoded file content
  • filename (required) - Name of the file to save
  • path (optional) - Destination folder path. If empty, shows folder picker dialog
  • overwrite (optional) - Overwrite existing file without prompt (default: false)

Returns

Promise<Object> - Result object:

{
    success: boolean,
    path: string,
    error?: string
}

Example

// Save generated content
const content = "Hello, World!";
const base64Data = btoa(content);

const result = await web.files.download({
    data: base64Data,
    filename: 'hello.txt',
    path: 'C:\\Documents',
    overwrite: true
});

if (result.success) {
    console.log('File saved to:', result.path);
}

// Let user choose location (shows folder picker)
const result = await web.files.download({
    data: base64Data,
    filename: 'export.json',
    path: '',  // Empty path shows dialog
    overwrite: false
});

Use Cases

  • Save generated reports or exports
  • Save user-created content
  • Save base64 data already in memory
  • Export application data to files
  • Save processed images or documents

When to Use

Use download() when:

  • You have base64 data already in memory
  • You're saving generated/exported content
  • You want user to choose save location (empty path)
  • You're saving processed data

Use downloadFromUrl() when:

  • You're downloading from HTTP/HTTPS URLs
  • You want to save directly from remote source
  • You need more efficient memory usage
  • You're downloading multiple files

Use fetchToBase64() when:

  • You need to fetch URL content as base64
  • You want to display or process the data
  • You need to create data URLs