0.1.1 • Published 3 years ago

@fengzos/file-transfer v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@fengzos/file-transfer

file-transfer

Install

npm install @fengzos/file-transfer
npx cap sync

iOS

To have files appear in the Files app, you must set the following keys to YES in Info.plist:

  • UIFileSharingEnabled (Application supports iTunes file sharing)
  • LSSupportsOpeningDocumentsInPlace (Supports opening documents in place)

Read about Configuring iOS for help.

Android

If using Directory.Documents or Directory.ExternalStorage, this API requires the following permissions be added to your AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Read about Setting Permissions in the Android Guide for more information on setting Android permissions.

Note that Directory.Documents and Directory.ExternalStorage are only available on Android 9 or older.

API

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


uploadFile(...)

uploadFile(options: UploadFileOptions) => Promise<UploadFileResult>

Uploads the specified file to the server URL provided using an HTTP multipart request.

ParamTypeDescription
optionsUploadFileOptionsUploadFileOptions

Returns: Promise<HttpResponse>


downloadFile(...)

downloadFile(options: DownloadFileOptions) => Promise<DownloadFileResult>

Downloads a file form a given URL and saves it to the specified directory.

ParamTypeDescription
optionsDownloadFileOptionsDownloadFileOptions

Returns: Promise<DownloadFileResult>


addListener('progress', ...)

addListener(eventName: 'progress', listenerFunc: ProgressListener) => Promise<PluginListenerHandle> & PluginListenerHandle
ParamType
eventName'progress'
listenerFuncProgressListener

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


removeAllListeners()

removeAllListeners() => Promise<void>

Interfaces

PermissionStatus

PropType
publicStoragePermissionState

HttpResponse

PropType
dataany
statusnumber
headersHttpHeaders
urlstring

HttpHeaders

UploadFileOptions

PropTypeDescription
urlstringThe URL to upload the file to
namestringThe field name to upload the file with
blobBlobFor uploading a file on the web, a JavaScript Blob to upload
filePathstringFor uploading a file natively, the path to the file on disk to upload
fileDirectoryDirectoryOptionally, the directory to look for the file in. If this option is used, filePath can be a relative path rather than absolute

DownloadFileResult

PropType
pathstring
blobBlob

DownloadFileOptions

PropTypeDescription
filePathstringThe path the downloaded file should be moved to
fileDirectoryDirectoryOptionally, the directory to put the file in If this option is used, filePath can be a relative path rather than absolute
progressbooleanOptionally, the switch that enables notifying listeners about downloaded progress If this option is used, progress event should be dispatched on every chunk received

PluginListenerHandle

PropType
remove() => Promise<void>

ProgressStatus

PropType
typeProgressType
urlstring
bytesnumber
contentLengthnumber

Type Aliases

PermissionState

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

UploadFileResult

HttpResponse

ProgressListener

(progress: ProgressStatus): void

ProgressType

'DOWNLOAD' | 'UPLOAD'

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
Library"LIBRARY"The Library directory On iOS it will use the Library directory. On Android it's the directory holding application files. Files will be deleted when the application is uninstalled.1.1.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
0.1.1

3 years ago

0.1.0

3 years ago