1.Introduction
Description: Basically AI2 wrapper of Storage Access Framework. Using this extension, you can get read and/or write access to a single document or tree document (and all of its children recursively).
Latest Version: 1.1
Released: 2021-09-16T18:30:00Z
Last Updated: 2021-11-01T18:30:00Z
2.Blocks
3.Documentation
Docs for: SAF
Events
DocumentCreated
Event invoked after creating document.Returns document's uri if operation was successful else returns error message
uriString | text
ErrorOccurred
Event indicating error/exception has occurred and returns origin method and error message.
methodName | text
errorMessage | text
GotCopyResult
Event invoked after getting copy document result.Response will be target document's uri if operation was successful else returns error message
successful | boolean
response | text
GotFilesList
Event invoked after getting files list
filesList | list
GotMoveResult
Event invoked after getting move document result.Response will be target document's uri if operation was successful else returns error message
successful | boolean
response | text
GotReadResult
Event invoked after reading from document.Returns content if operation was successful else returns error message
result | any
GotUri
Event invoked when user selects a document or tree from SAF file picker
uri | any
uriString | text
GotWriteResult
Event invoked after writing to document.Returns document's uri if operation was successful else returns error message
response | text
Methods
BuildChildDocumentsUriUsingTree
Builds child documents id using tree (documents which is child of parent document) uri and its parent document id
treeUri | text
parentDocumentId | text
Return type : text
BuildDocumentUriUsingTree
Builds document uri using tree uri and document id
treeUri | text
documentId | text
Return type : text
CopyDocument
Tries to copy document from source uri to target dir
sourceUri | text
targetParentUri | text
CreateDocument
Creates a new and empty document.If document already exists then an incremental value will be suffixed.
parentDocumentUri | text
fileName | text
mimeType | text
CreateFlags
Combines two flags and returns resulting flag
f1 | number
f2 | number
Return type : number
DeleteDocument
Tries to delete document from given uri and returns result
uriString | text
Return type : boolean
GetDisplayName
Returns display name of given document uri
documentUri | text
Return type : text
GetDocumentId
Returns document id of an uri (should only be grand child)
uriString | text
Return type : text
GetLastModifiedTime
Returns last modified time (epoch) of given document uri
documentUri | text
Return type : text
GetMimeType
Returns mime type of given document uri
documentUri | text
Return type : text
GetSize
Returns size (in bytes) of given document uri
documentUri | text
Return type : text
GetTreeDocumentId
Returns document id of tree uri (should be either tree uri itself or a direct child uri)
uriString | text
Return type : text
IsChildDocumentUri
Returns whether second uri is child of first uri
parentUri | text
childUri | text
Return type : boolean
IsCopySupported
Returns whether document can be copied or not
documentUri | text
Return type : boolean
IsDeleteSupported
Returns whether document is deletable or not
documentUri | text
Return type : boolean
IsDocumentUri
Returns whether given uri is a document uri
uriString | text
Return type : boolean
IsMoveSupported
Returns whether document is movable or not
documentUri | text
Return type : boolean
IsReadGranted
Returns whether read is available for given uri
uri | text
Return type : boolean
IsRenameSupported
Returns whether document is deletable or not
documentUri | text
Return type : boolean
IsTreeUri
Returns whether given uri is a tree uri
uriString | text
Return type : boolean
IsWriteGranted
Returns whether write is available for given uri
uri | text
Return type : boolean
ListFiles
Tries to list files from given dir
dirUri | text
dirDocumentId | text
MoveDocument
Tries to move document from source uri to target dir
sourceUri | text
sourceParentUri | text
targetParentUri | text
OpenDocumentTree
Prompts user to select a document tree
title | text
initialDir | text
OpenSingleDocument
Prompts user to select a single file
title | text
type | text
extraMimeTypes | list
ReadAsByteArray
Reads content of document as byte array
uriString | text
ReadFromFile
Reads from given document as text
uriString | text
ReleasePermission
Relinquish a persisted URI permission grant
uri | text
flags | number
RenameDocument
Tries to rename a document and returns updated uri
documentUri | text
displayName | text
Return type : text
StringFromUriObject
Convert uri to string
uri | any
Return type : text
StringToUriObject
Converts string to uri
uriString | text
Return type : any
TakePersistableUriPermission
Take a persistable URI permission grant that has been offered. Once taken, the permission grant will be remembered across device reboots.
uri | any
flags | number
WriteAsByteArray
Writes byte array to given document
uriString | text
byteArray | any
WriteToFile
Writes to given uri
uriString | text
content | text
Properties
DocumentDirMimeType
Returns mime type of document dir
Property Type : read-only
Accepts : text
FlagGrantReadPermission
Flag to get write permission
Property Type : read-only
Accepts : number
FlagGrantWritePermission
Flag to get read permission
Property Type : read-only
Accepts : number
4.Usages
will be updated frequently
1.Open document tree
2.Get access (not necessary for one-time usage)
3.Build child document uri
- if document is direct child
- if document is grandchild
4.Read file/Set picture
Examples by Power Users
I am thankful to them for their efforts.
5.Download
Aix: com.sunny.saf.aix (30.6 KB)
6.Open Source
7.Liked my work/Want to donate
Thank you
8. ChangeLog
ChangeLog Version 1.1
New Blocks
Changes
- Removed
category
param fromOpenSingleDocument
method -
GotCopyResult
andGotMoveResult
now return resulting/target document's uri
Bug Fixes
- Fixed issue in write methods
- Fixed null pointer exception when SAF picker was cancelled by user
Hope it helps!