0.1.3 • Published 1 year ago

@vorujack/capacitor-filesystem v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@vorujack/capacitor-filesystem

Capacitor File Access Plugin include electron

Install

npm install @vorujack/capacitor-filesystem
npx cap sync

API

readFile(...)

readFile(options: ReadFileOptions) => Promise<ReadFileResult>

Read a file from disk

ParamType
optionsReadFileOptions

Returns: Promise<ReadFileResult>

Since: 1.0.0


writeFile(...)

writeFile(options: WriteFileOptions) => Promise<WriteFileResult>

Write a file to disk in the specified location on device

ParamType
optionsWriteFileOptions

Returns: Promise<WriteFileResult>

Since: 1.0.0


appendFile(...)

appendFile(options: AppendFileOptions) => Promise<void>

Append to a file on disk in the specified location on device

ParamType
optionsAppendFileOptions

Since: 1.0.0


deleteFile(...)

deleteFile(options: DeleteFileOptions) => Promise<void>

Delete a file from disk

ParamType
optionsDeleteFileOptions

Since: 1.0.0


mkdir(...)

mkdir(options: MkdirOptions) => Promise<void>

Create a directory.

ParamType
optionsMkdirOptions

Since: 1.0.0


rmdir(...)

rmdir(options: RmdirOptions) => Promise<void>

Remove a directory

ParamType
optionsRmdirOptions

Since: 1.0.0


readdir(...)

readdir(options: ReaddirOptions) => Promise<ReaddirResult>

Return a list of files from the directory (not recursive)

ParamType
optionsReaddirOptions

Returns: Promise<ReaddirResult>

Since: 1.0.0


getUri(...)

getUri(options: GetUriOptions) => Promise<GetUriResult>

Return full File URI for a path and directory

ParamType
optionsGetUriOptions

Returns: Promise<GetUriResult>

Since: 1.0.0


stat(...)

stat(options: StatOptions) => Promise<StatResult>

Return data about a file

ParamType
optionsStatOptions

Returns: Promise<StatResult>

Since: 1.0.0


rename(...)

rename(options: RenameOptions) => Promise<void>

Rename a file or directory

ParamType
optionsCopyOptions

Since: 1.0.0


copy(...)

copy(options: CopyOptions) => Promise<void>

Copy a file or directory

ParamType
optionsCopyOptions

Since: 1.0.0


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Check read/write permissions. Required on Android, only when using Directory.Documents or Directory.ExternalStorage.

Returns: Promise<PermissionStatus>

Since: 1.0.0


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Request read/write permissions. Required on Android, only when using Directory.Documents or Directory.ExternalStorage.

Returns: Promise<PermissionStatus>

Since: 1.0.0


Interfaces

ReadFileResult

PropTypeDescriptionSince
datastringThe string representation of the data contained in the file1.0.0

ReadFileOptions

PropTypeDescriptionSince
pathstringThe path of the file to read1.0.0
directoryDirectoryThe Directory to read the file from1.0.0
encodingEncodingThe encoding to read the file in, if not provided, data is read as binary and returned as base64 encoded. Pass Encoding.UTF8 to read data as string1.0.0

WriteFileResult

PropTypeDescriptionSince
uristringThe uri where the file was written into1.0.0

WriteFileOptions

PropTypeDescriptionDefaultSince
pathstringThe path of the file to write1.0.0
datastringThe data to write1.0.0
directoryDirectoryThe Directory to store the file in1.0.0
encodingEncodingThe encoding to write the file in. If not provided, data is written as base64 encoded. Pass Encoding.UTF8 to write data as string1.0.0
recursivebooleanWhether to create any missing parent directories.false1.0.0

AppendFileOptions

PropTypeDescriptionSince
pathstringThe path of the file to append1.0.0
datastringThe data to write1.0.0
directoryDirectoryThe Directory to store the file in1.0.0
encodingEncodingThe encoding to write the file in. If not provided, data is written as base64 encoded. Pass Encoding.UTF8 to write data as string1.0.0

DeleteFileOptions

PropTypeDescriptionSince
pathstringThe path of the file to delete1.0.0
directoryDirectoryThe Directory to delete the file from1.0.0

MkdirOptions

PropTypeDescriptionDefaultSince
pathstringThe path of the new directory1.0.0
directoryDirectoryThe Directory to make the new directory in1.0.0
recursivebooleanWhether to create any missing parent directories as well.false1.0.0

RmdirOptions

PropTypeDescriptionDefaultSince
pathstringThe path of the directory to remove1.0.0
directoryDirectoryThe Directory to remove the directory from1.0.0
recursivebooleanWhether to recursively remove the contents of the directoryfalse1.0.0

ReaddirResult

PropTypeDescriptionSince
filesstring[]List of files and directories inside the directory1.0.0

ReaddirOptions

PropTypeDescriptionSince
pathstringThe path of the directory to read1.0.0
directoryDirectoryThe Directory to list files from1.0.0

GetUriResult

PropTypeDescriptionSince
uristringThe uri of the file1.0.0

GetUriOptions

PropTypeDescriptionSince
pathstringThe path of the file to get the URI for1.0.0
directoryDirectoryThe Directory to get the file under1.0.0

StatResult

PropTypeDescriptionSince
typestringType of the file1.0.0
sizenumberSize of the file1.0.0
ctimenumberTime of creation in milliseconds. It's not available on Android 7 and older devices.1.0.0
mtimenumberTime of last modification in milliseconds.1.0.0
uristringThe uri of the file1.0.0

StatOptions

PropTypeDescriptionSince
pathstringThe path of the file to get data about1.0.0
directoryDirectoryThe Directory to get the file under1.0.0

CopyOptions

PropTypeDescriptionSince
fromstringThe existing file or directory1.0.0
tostringThe destination file or directory1.0.0
directoryDirectoryThe Directory containing the existing file or directory1.0.0
toDirectoryDirectoryThe Directory containing the destination file or directory. If not supplied will use the 'directory' parameter as the destination1.0.0

PermissionStatus

PropType
publicStoragePermissionState

Type Aliases

RenameOptions

CopyOptions

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

Enums

Directory

MembersValueDescriptionSince
Documents"DOCUMENTS"The Documents directory On iOS it's the app's documents directory. Use this directory to store user-generated content. On Android it's the Public Documents folder, so it's accessible from other apps. It's not accesible on Android 10 unless the app enables legacy External Storage by adding android:requestLegacyExternalStorage="true" in the application tag in the AndroidManifest.xml. It's not accesible on Android 11 or newer.1.0.0
Data"DATA"The Data directory On iOS it will use the Documents directory On Android it's the directory holding application files. Files will be deleted when the application is uninstalled.1.0.0
Cache"CACHE"The Cache directory Can be deleted in cases of low memory, so use this directory to write app-specific files that your app can re-create easily.1.0.0
External"EXTERNAL"The external directory On iOS it will use the Documents directory On Android it's the directory on the primary shared/external storage device where the application can place persistent files it owns. These files are internal to the applications, and not typically visible to the user as media. Files will be deleted when the application is uninstalled.1.0.0
ExternalStorage"EXTERNAL_STORAGE"The external storage directory On iOS it will use the Documents directory On Android it's the primary shared/external storage directory. It's not accesible on Android 10 unless the app enables legacy External Storage by adding android:requestLegacyExternalStorage="true" in the application tag in the AndroidManifest.xml. It's not accesible on Android 11 or newer.1.0.0

Encoding

MembersValueDescriptionSince
UTF8"utf8"Eight-bit UCS Transformation Format1.0.0
ASCII"ascii"Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set This encoding is only supported on Android.1.0.0
UTF16"utf16"Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark This encoding is only supported on Android.1.0.0
0.1.3

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago