sharing

Sharing Items

This module allows you to share items, to import files and to open URLs.

class sharing.FilePicker

A class representing a file picker. Presents an UIDocumentPickerViewController.

A class representing a file picker.

Example:

filePicker = sharing.FilePicker()
filePicker.file_types = ["public.data"]
filePicker.allows_multiple_selection = True

def files_picked() -> None:
    files = sharing.picked_files()
    sharing.share_items(files)

filePicker.completion = files_picked
sharing.pick_documents(filePicker)
allows_multiple_selection = False

Allow multiple selection or not.

completion = None

The code to execute when files where picked.

file_types = []

Document types that can be opened.

urls = []

Picked URLs.

sharing.open_url(url: str)

Opens the given URL.

Parameters:url – URL to open. Can be a String or an Objective-C NSURL.
sharing.pick_documents(filePicker: sharing.FilePicker)

Pick documents with given parameters as a FilePicker.

Parameters:filePicker – The parameters of the file picker to be presented.
sharing.picked_files() → List[str]

Returns paths of files picked with pickDocumentsWithFilePicker.

sharing.quick_look(path: str)

Previews given file.

This function doesn’t block the current thread. You can call this function multiple times and the file path will be appended to the current Preview controller. Thread safe.

Parameters:path – Path of the image to preview.
sharing.share_items(items: object)

Opens a share sheet with given items.

Parameters:items – Items to be shared with the sheet.