Documents API for Pega Mobile Client
Pega Mobile Client provides JavaScript APIs that you can access from Pega Platform. The Documents API consists of methods that you can use to interact with documents stored on the mobile device.
window.pms.plugins.documents
An object that exposes access to picking, sharing and previewing of documents that are stored on the device.
Properties
None.
Events
None.
Methods
pick(options)
Presents a native UI for capturing photos and videos, recording audio, as well as selecting documents that are stored on the device.
- Parameters
options
Optional. When passed, the options parameter customizes the picking operation. Supported values include:
imageSize
Maximum length of the longer side of the returned image, expressed in pixels. The images are downscaled to match the given size, but not upscaled. The default value is
0
, which indicates no scaling. This setting applies to JPEG images only.imageQuality
Quality of the returned image, expressed as a value within the
0.0
- 1.0
range, where0.0
represents maximum compression (or the lowest quality) and1.0
represents minimum compression (or the best quality). The default value is1.0
. This setting applies to JPEG images only and does not affect media content that is saved in a media library of the device.maximumDuration
Maximum duration of an audio or video recording, expressed in seconds. The default value is
600
seconds (10 minutes). This setting does not apply to prerecorded media content that is picked from a media library of the device or a cloud storage provider.saveToLibrary
A Boolean property that indicates whether the media that is being captured is saved into a media library of the device. The default value is
false
.videoPreset
A string constant that specifies the name of the preset template for video export.
'native'
No conversion. This is the default setting.
'1080p'
Video is converted to a 1080p format (1920 x 1080).
'720p'
Video is converted to a 720p format (1280 x 720).
'540p'
Video is converted to a 540p format (960 x 540).
'360p'
Video is converted to a 360p format (640 x 360).
- Return value
- A
Promise
that, when resolved, returns a handle for the document that is picked by the user. The handle can be passed to thesend
,share
, orpreview
APIs.The handle is an object that defines the following properties:
id
The unique identifier of the document. The value is not transferable between devices.
name
Name of the document.
size
Size of the document in bytes.
type
MIME type of the document.
send(handle, url, mimeType, queryString)
Sends local documents to a Pega instance in an online-only scenario (without the help of the client store).
- Parameters
handle
A document handle that is returned by the
pick
API.url
A remote URL address, to which the file is sent.
mimeType
Optional. When passed, the value overrides the MIME type that was determined automatically based on the file name and contents.
queryString
Optional. A query string of custom parameters that is sent as the first part of a multipart request.
- Return value
- A
Promise
that, when resolved, indicates that the file was uploaded without errors and returns an HTTP response summary.The response summary is an object that defines the following properties:
code
The HTTP response status code.
body
Contents of the HTTP response.
share(object, mimeType)
Presents a native UI for sharing documents with external applications.
- Parameters
object
A document handle that is returned by the
pick
API or a URL address of a remote document.mimeType
Optional. When passed, the value overrides the MIME type of the document.
- Return value
- A
Promise
that, when resolved, indicates that the user dismissed the share UI.
preview(object, mimeType)
Presents a native UI for previewing documents.
- Parameters
object
A document handle that is returned by the
pick
API or a URL address of a remote document.mimeType
Optional. When passed, the value overrides the MIME type of the document.
- Return value
- A
Promise
that, when resolved, indicates that the user dismissed the preview UI.
Previous topic Client Store API for Pega Mobile Client