@capgo/capacitor-file-picker 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapgoCapacitorFilePicker'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '15.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapgoCapacitorFilePicker",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "CapgoCapacitorFilePicker",
10
+ targets: ["CapgoFilePickerPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "CapgoFilePickerPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/CapgoFilePickerPlugin"),
23
+ .testTarget(
24
+ name: "CapgoFilePickerPluginTests",
25
+ dependencies: ["CapgoFilePickerPlugin"],
26
+ path: "ios/Tests/CapgoFilePickerPluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,403 @@
1
+ # @capgo/capacitor-file-picker
2
+ <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
+
4
+ <div align="center">
5
+ <h2><a href="https://capgo.app/?ref=plugin_file_picker"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin_file_picker"> Missing a feature? We'll build the plugin for you 💪</a></h2>
7
+ </div>
8
+
9
+ File picker Capacitor plugin - Pick files, images, videos, and directories
10
+
11
+ ## Why Capacitor File Picker?
12
+
13
+ A comprehensive file picker plugin with **full native support** for iOS and Android:
14
+
15
+ - **Pick Files** - Select any file type with MIME type filtering
16
+ - **Pick Images** - Native photo library picker with multi-select
17
+ - **Pick Videos** - Native video picker with duration and dimensions
18
+ - **Pick Media** - Combined image and video picker
19
+ - **Pick Directory** - Select folders (Android/iOS)
20
+ - **HEIC to JPEG** - Convert HEIC images to JPEG (iOS only)
21
+ - **Copy Files** - Copy files to new locations
22
+ - **File Metadata** - Get size, dimensions, duration, and more
23
+
24
+ ## Documentation
25
+
26
+ The most complete doc is available here: https://capgo.app/docs/plugins/file-picker/
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ npm install @capgo/capacitor-file-picker
32
+ npx cap sync
33
+ ```
34
+
35
+ ## Requirements
36
+
37
+ - iOS: iOS 15.0+
38
+ - Android: API 24+ (Android 7.0+)
39
+ - Web: Modern browsers with File API support
40
+
41
+ ## API
42
+
43
+ <docgen-index>
44
+
45
+ * [`pickFiles(...)`](#pickfiles)
46
+ * [`pickImages(...)`](#pickimages)
47
+ * [`pickVideos(...)`](#pickvideos)
48
+ * [`pickMedia(...)`](#pickmedia)
49
+ * [`pickDirectory()`](#pickdirectory)
50
+ * [`convertHeicToJpeg(...)`](#convertheictojpeg)
51
+ * [`copyFile(...)`](#copyfile)
52
+ * [`checkPermissions()`](#checkpermissions)
53
+ * [`requestPermissions()`](#requestpermissions)
54
+ * [`addListener('pickerDismissed', ...)`](#addlistenerpickerdismissed-)
55
+ * [`removeAllListeners()`](#removealllisteners)
56
+ * [`getPluginVersion()`](#getpluginversion)
57
+ * [Interfaces](#interfaces)
58
+ * [Type Aliases](#type-aliases)
59
+
60
+ </docgen-index>
61
+
62
+ <docgen-api>
63
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
64
+
65
+ Capacitor File Picker Plugin interface for selecting files, images, videos, and directories.
66
+
67
+ ### pickFiles(...)
68
+
69
+ ```typescript
70
+ pickFiles(options?: PickFilesOptions | undefined) => Promise<PickFilesResult>
71
+ ```
72
+
73
+ Pick one or more files from the device.
74
+
75
+ | Param | Type | Description |
76
+ | ------------- | ------------------------------------------------------------- | --------------------------- |
77
+ | **`options`** | <code><a href="#pickfilesoptions">PickFilesOptions</a></code> | - Options for picking files |
78
+
79
+ **Returns:** <code>Promise&lt;<a href="#pickfilesresult">PickFilesResult</a>&gt;</code>
80
+
81
+ **Since:** 8.0.0
82
+
83
+ --------------------
84
+
85
+
86
+ ### pickImages(...)
87
+
88
+ ```typescript
89
+ pickImages(options?: PickMediaOptions | undefined) => Promise<PickFilesResult>
90
+ ```
91
+
92
+ Pick one or more images from the gallery.
93
+ Android/iOS only.
94
+
95
+ | Param | Type | Description |
96
+ | ------------- | ------------------------------------------------------------- | ---------------------------- |
97
+ | **`options`** | <code><a href="#pickmediaoptions">PickMediaOptions</a></code> | - Options for picking images |
98
+
99
+ **Returns:** <code>Promise&lt;<a href="#pickfilesresult">PickFilesResult</a>&gt;</code>
100
+
101
+ **Since:** 8.0.0
102
+
103
+ --------------------
104
+
105
+
106
+ ### pickVideos(...)
107
+
108
+ ```typescript
109
+ pickVideos(options?: PickMediaOptions | undefined) => Promise<PickFilesResult>
110
+ ```
111
+
112
+ Pick one or more videos from the gallery.
113
+ Android/iOS only.
114
+
115
+ | Param | Type | Description |
116
+ | ------------- | ------------------------------------------------------------- | ---------------------------- |
117
+ | **`options`** | <code><a href="#pickmediaoptions">PickMediaOptions</a></code> | - Options for picking videos |
118
+
119
+ **Returns:** <code>Promise&lt;<a href="#pickfilesresult">PickFilesResult</a>&gt;</code>
120
+
121
+ **Since:** 8.0.0
122
+
123
+ --------------------
124
+
125
+
126
+ ### pickMedia(...)
127
+
128
+ ```typescript
129
+ pickMedia(options?: PickMediaOptions | undefined) => Promise<PickFilesResult>
130
+ ```
131
+
132
+ Pick one or more images or videos from the gallery.
133
+ Android/iOS only.
134
+
135
+ | Param | Type | Description |
136
+ | ------------- | ------------------------------------------------------------- | --------------------------- |
137
+ | **`options`** | <code><a href="#pickmediaoptions">PickMediaOptions</a></code> | - Options for picking media |
138
+
139
+ **Returns:** <code>Promise&lt;<a href="#pickfilesresult">PickFilesResult</a>&gt;</code>
140
+
141
+ **Since:** 8.0.0
142
+
143
+ --------------------
144
+
145
+
146
+ ### pickDirectory()
147
+
148
+ ```typescript
149
+ pickDirectory() => Promise<PickDirectoryResult>
150
+ ```
151
+
152
+ Pick a directory from the device.
153
+ Android/iOS only.
154
+
155
+ **Returns:** <code>Promise&lt;<a href="#pickdirectoryresult">PickDirectoryResult</a>&gt;</code>
156
+
157
+ **Since:** 8.0.0
158
+
159
+ --------------------
160
+
161
+
162
+ ### convertHeicToJpeg(...)
163
+
164
+ ```typescript
165
+ convertHeicToJpeg(options: ConvertHeicToJpegOptions) => Promise<ConvertHeicToJpegResult>
166
+ ```
167
+
168
+ Convert a HEIC image to JPEG format.
169
+ iOS only.
170
+
171
+ | Param | Type | Description |
172
+ | ------------- | ----------------------------------------------------------------------------- | ---------------------------- |
173
+ | **`options`** | <code><a href="#convertheictojpegoptions">ConvertHeicToJpegOptions</a></code> | - Options for the conversion |
174
+
175
+ **Returns:** <code>Promise&lt;<a href="#convertheictojpegresult">ConvertHeicToJpegResult</a>&gt;</code>
176
+
177
+ **Since:** 8.0.0
178
+
179
+ --------------------
180
+
181
+
182
+ ### copyFile(...)
183
+
184
+ ```typescript
185
+ copyFile(options: CopyFileOptions) => Promise<void>
186
+ ```
187
+
188
+ Copy a file to a new location.
189
+
190
+ | Param | Type | Description |
191
+ | ------------- | ----------------------------------------------------------- | ------------------------------ |
192
+ | **`options`** | <code><a href="#copyfileoptions">CopyFileOptions</a></code> | - Options for copying the file |
193
+
194
+ **Since:** 8.0.0
195
+
196
+ --------------------
197
+
198
+
199
+ ### checkPermissions()
200
+
201
+ ```typescript
202
+ checkPermissions() => Promise<PermissionStatus>
203
+ ```
204
+
205
+ Check permissions for reading files.
206
+ Android only.
207
+
208
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
209
+
210
+ **Since:** 8.0.0
211
+
212
+ --------------------
213
+
214
+
215
+ ### requestPermissions()
216
+
217
+ ```typescript
218
+ requestPermissions() => Promise<PermissionStatus>
219
+ ```
220
+
221
+ Request permissions for reading files.
222
+ Android only.
223
+
224
+ **Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>
225
+
226
+ **Since:** 8.0.0
227
+
228
+ --------------------
229
+
230
+
231
+ ### addListener('pickerDismissed', ...)
232
+
233
+ ```typescript
234
+ addListener(eventName: 'pickerDismissed', listenerFunc: PickerDismissedListener) => Promise<PluginListenerHandle>
235
+ ```
236
+
237
+ Add a listener for the picker dismissed event.
238
+ iOS only.
239
+
240
+ | Param | Type | Description |
241
+ | ------------------ | --------------------------------------------------------------------------- | ----------------------- |
242
+ | **`eventName`** | <code>'pickerDismissed'</code> | - The event name |
243
+ | **`listenerFunc`** | <code><a href="#pickerdismissedlistener">PickerDismissedListener</a></code> | - The listener function |
244
+
245
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
246
+
247
+ **Since:** 8.0.0
248
+
249
+ --------------------
250
+
251
+
252
+ ### removeAllListeners()
253
+
254
+ ```typescript
255
+ removeAllListeners() => Promise<void>
256
+ ```
257
+
258
+ Remove all listeners for this plugin.
259
+
260
+ **Since:** 8.0.0
261
+
262
+ --------------------
263
+
264
+
265
+ ### getPluginVersion()
266
+
267
+ ```typescript
268
+ getPluginVersion() => Promise<{ version: string; }>
269
+ ```
270
+
271
+ Get the native Capacitor plugin version.
272
+
273
+ **Returns:** <code>Promise&lt;{ version: string; }&gt;</code>
274
+
275
+ **Since:** 8.0.0
276
+
277
+ --------------------
278
+
279
+
280
+ ### Interfaces
281
+
282
+
283
+ #### PickFilesResult
284
+
285
+ Result of picking files.
286
+
287
+ | Prop | Type | Description |
288
+ | ----------- | ------------------------- | --------------------- |
289
+ | **`files`** | <code>PickedFile[]</code> | Array of picked files |
290
+
291
+
292
+ #### PickedFile
293
+
294
+ Represents a picked file.
295
+
296
+ | Prop | Type | Description |
297
+ | ---------------- | ------------------- | ----------------------------------------------------------------------- |
298
+ | **`name`** | <code>string</code> | The name of the file |
299
+ | **`path`** | <code>string</code> | The path to the file |
300
+ | **`mimeType`** | <code>string</code> | The MIME type of the file |
301
+ | **`size`** | <code>number</code> | The size of the file in bytes |
302
+ | **`data`** | <code>string</code> | The base64 encoded data of the file. Only present if readData was true. |
303
+ | **`blob`** | <code>Blob</code> | The Blob instance of the file. Web only. |
304
+ | **`width`** | <code>number</code> | Width in pixels (images/videos only) |
305
+ | **`height`** | <code>number</code> | Height in pixels (images/videos only) |
306
+ | **`duration`** | <code>number</code> | Duration in seconds (videos only) |
307
+ | **`modifiedAt`** | <code>number</code> | Last modified timestamp in milliseconds |
308
+
309
+
310
+ #### PickFilesOptions
311
+
312
+ Options for picking files.
313
+
314
+ | Prop | Type | Description | Default |
315
+ | -------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
316
+ | **`types`** | <code>string[]</code> | List of accepted MIME types or file extensions. On iOS, only MIME types are supported. Examples: ['image/*'], ['application/pdf'], ['.pdf', '.doc'] | |
317
+ | **`limit`** | <code>number</code> | Maximum number of files to pick. Set to 0 for unlimited (platform default). | <code>0</code> |
318
+ | **`readData`** | <code>boolean</code> | Whether to read the file data as base64. Note: Reading large files may cause memory issues. | <code>false</code> |
319
+
320
+
321
+ #### PickMediaOptions
322
+
323
+ Options for picking media (images/videos).
324
+
325
+ | Prop | Type | Description | Default |
326
+ | --------------------- | -------------------- | ------------------------------------------------------------------------------------------- | ------------------ |
327
+ | **`limit`** | <code>number</code> | Maximum number of files to pick. Set to 0 for unlimited (platform default). | <code>0</code> |
328
+ | **`readData`** | <code>boolean</code> | Whether to read the file data as base64. Note: Reading large files may cause memory issues. | <code>false</code> |
329
+ | **`skipTranscoding`** | <code>boolean</code> | iOS only: Skip transcoding of videos. | <code>false</code> |
330
+ | **`ordered`** | <code>boolean</code> | iOS 15+ only: Show ordered selection badges. | <code>false</code> |
331
+
332
+
333
+ #### PickDirectoryResult
334
+
335
+ Result of picking a directory.
336
+
337
+ | Prop | Type | Description |
338
+ | ---------- | ------------------- | ---------------------------------- |
339
+ | **`path`** | <code>string</code> | The path to the selected directory |
340
+
341
+
342
+ #### ConvertHeicToJpegResult
343
+
344
+ Result of HEIC to JPEG conversion.
345
+
346
+ | Prop | Type | Description |
347
+ | ---------- | ------------------- | ----------------------------------- |
348
+ | **`path`** | <code>string</code> | The path to the converted JPEG file |
349
+
350
+
351
+ #### ConvertHeicToJpegOptions
352
+
353
+ Options for converting HEIC to JPEG.
354
+
355
+ | Prop | Type | Description | Default |
356
+ | ------------- | ------------------- | --------------------------------------------- | ---------------- |
357
+ | **`path`** | <code>string</code> | The path to the HEIC file to convert | |
358
+ | **`quality`** | <code>number</code> | The compression quality for JPEG (0.0 - 1.0). | <code>0.9</code> |
359
+
360
+
361
+ #### CopyFileOptions
362
+
363
+ Options for copying a file.
364
+
365
+ | Prop | Type | Description | Default |
366
+ | --------------- | -------------------- | ------------------------------------------- | ------------------ |
367
+ | **`from`** | <code>string</code> | Source file path | |
368
+ | **`to`** | <code>string</code> | Destination file path | |
369
+ | **`overwrite`** | <code>boolean</code> | Whether to overwrite if destination exists. | <code>false</code> |
370
+
371
+
372
+ #### PermissionStatus
373
+
374
+ Permission status for file access.
375
+
376
+ | Prop | Type | Description |
377
+ | ------------------------- | ----------------------------------------------------------- | ------------------------------------------------------ |
378
+ | **`readExternalStorage`** | <code><a href="#permissionstate">PermissionState</a></code> | Whether permission to read media files is granted |
379
+ | **`accessMediaLocation`** | <code><a href="#permissionstate">PermissionState</a></code> | Whether permission to access media location is granted |
380
+
381
+
382
+ #### PluginListenerHandle
383
+
384
+ | Prop | Type |
385
+ | ------------ | ----------------------------------------- |
386
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
387
+
388
+
389
+ ### Type Aliases
390
+
391
+
392
+ #### PermissionState
393
+
394
+ <code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>
395
+
396
+
397
+ #### PickerDismissedListener
398
+
399
+ Listener callback for picker dismissed event.
400
+
401
+ <code>(event: null): void</code>
402
+
403
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.13.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace = "app.capgo.capacitor.filepicker"
22
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError = false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_21
41
+ targetCompatibility JavaVersion.VERSION_21
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>