filepicker

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package filepicker lets someone choose a file with the system's picker. The file comes back as bytes, so it works under `nimbus native dev` too.

nimbus native plugin add file-picker

f, err := filepicker.Pick(ctx, filepicker.Options{Types: []string{"application/pdf"}})
if plugin.IsCode(err, plugin.Cancelled) { return }

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name string `json:"name"` // its file name
	Type string `json:"type"` // its media type
	Data []byte `json:"data"` // its contents
}

File is what was chosen.

func Pick

func Pick(ctx context.Context, o Options) (File, error)

Pick opens the picker. It fails with plugin.Cancelled if they back out.

type Options

type Options struct {
	Types    []string `json:"types"`    // MIME types, such as "application/pdf"; empty for any
	MaxBytes int64    `json:"maxBytes"` // larger files fail; 0 means 20 MB
}

Options narrows what can be chosen.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL