You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs: Explicitly document which paramters of `HttpOptions` are used.
References: https://outsystemsrd.atlassian.net/browse/IONIC-52
* docs: Notes on `HttpOptions` and error codes
* docs: Add example usage section
* docs: mention Filesystem plugin for getting path
References: https://outsystemsrd.atlassian.net/browse/IONIC-52
* docs: Add note about chunkedMode and http headers
References: #10
* chore: minor update on example code
* chore: fix lint issues
// If you want to avoid that, you can set the 'Content-Type' header explicitly.
64
+
'Content-Type': 'application/octet-stream',
65
+
},
66
+
progress: false
67
+
});
68
+
// get server response and other info from result - see `UploadFileResult` interface
69
+
} catch(error) {
70
+
// handle error - see `FileTransferError` interface for what error information is returned
71
+
}
72
+
```
73
+
74
+
12
75
## API
13
76
14
77
<docgen-index>
@@ -21,6 +84,10 @@ npx cap sync
21
84
22
85
</docgen-index>
23
86
87
+
Note: Some of the input options come from `HttpOptions` in `@capacitor/core`, but the plugin does not use all parameters from `HttpOptions`. The ones that are used are documented below.
88
+
89
+
For list of existing error codes, see [Errors](#errors).
90
+
24
91
<docgen-api>
25
92
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
26
93
@@ -108,10 +175,24 @@ Remove all listeners for this plugin.
|**`path`**| <code>string</code> | The full file path the downloaded file should be moved to. | 1.0.0 |
114
-
|**`progress`**| <code>boolean</code> | If true, progress event will be dispatched on every chunk received. See addListener() for more information. Chunks are throttled to every 100ms on Android/iOS to avoid slowdowns. | 1.0.0 |
|**`url`**| <code>string</code> | The URL to download the file from. | 1.0.0 |
181
+
|**`path`**| <code>string</code> | The full file path the downloaded file should be moved to. You may use a plugin like `@capacitor/filesystem` to get a complete file path. | 1.0.0 |
182
+
|**`progress`**| <code>boolean</code> | If true, progress event will be dispatched on every chunk received. See addListener() for more information. Chunks are throttled to every 100ms on Android/iOS to avoid slowdowns. Default is `false`. | 1.0.0 |
183
+
|**`method`**| <code>string</code> | The Http Request method to run. (Default is GET) | 1.0.0 |
184
+
|**`params`**| <code><ahref="#httpparams">HttpParams</a></code> | URL parameters to append to the request. This <ahref="#httpparams">`HttpParams`</a> interface comes from `@capacitor/core`. | 1.0.0 |
185
+
|**`headers`**| <code><ahref="#httpheaders">HttpHeaders</a></code> | Http Request headers to send with the request. This <ahref="#httpheaders">`HttpHeaders`</a> interface comes from `@capacitor/core`. | 1.0.0 |
186
+
|**`readTimeout`**| <code>number</code> | How long to wait to read additional data in milliseconds. Resets each time new data is received. Default is 60,000 milliseconds (1 minute). Not supported on web. | 1.0.0 |
187
+
|**`connectTimeout`**| <code>number</code> | How long to wait for the initial connection in milliseconds. Default is 60,000 milliseconds (1 minute). In iOS, there's no real distinction between `connectTimeout`and `readTimeout`. Plugin tries to use `connectTimeout`, if not uses `readTimeout`, if not uses default | 1.0.0 |
188
+
|**`disableRedirects`**| <code>boolean</code> | Sets whether automatic HTTP redirects should be disabled | 1.0.0 |
189
+
|**`shouldEncodeUrlParams`**| <code>boolean</code> | Use this option if you need to keep the URL unencoded in certain cases (already encoded, azure/firebase testing, etc.). The default is `true`. Not supported on web. | 1.0.0 |
190
+
191
+
192
+
#### HttpParams
193
+
194
+
195
+
#### HttpHeaders
115
196
116
197
117
198
#### UploadFileResult
@@ -126,14 +207,22 @@ Remove all listeners for this plugin.
|**`path`**| <code>string</code> | Full file path of the file to upload. | 1.0.0 |
132
-
|**`blob`**| <code>Blob</code> | Blob data to upload. Will use this instead of path if provided. This is only available on web. | 1.0.0 |
133
-
|**`chunkedMode`**| <code>boolean</code> | Whether to upload data in a chunked streaming mode. Not supported on web. | 1.0.0 |
134
-
|**`mimeType`**| <code>string</code> | Mime type of the data to upload. Only used if "Content-Type" header was not provided. | 1.0.0 |
135
-
|**`fileKey`**| <code>string</code> | Type of form element. The default is set to "file". Only used if "Content-Type" header was not provided. | 1.0.0 |
136
-
|**`progress`**| <code>boolean</code> | If true, progress event will be dispatched on every chunk received. See addListener() for more information. Chunks are throttled to every 100ms on Android/iOS to avoid slowdowns. | 1.0.0 |
|**`url`**| <code>string</code> | The URL to upload the file to. | 1.0.0 |
213
+
|**`path`**| <code>string</code> | Full file path of the file to upload. You may use a plugin like `@capacitor/filesystem` to get a complete file path. | 1.0.0 |
214
+
|**`blob`**| <code>Blob</code> | Blob data to upload. Will use this instead of path if provided. This is only available on web. | 1.0.0 |
215
+
|**`chunkedMode`**| <code>boolean</code> | Whether to upload data in a chunked streaming mode. Not supported on web. Note: The upload uses `Content-Type: multipart/form-data`, when `chunkedMode` is `true`. Depending on your backend server, this can cause the upload to fail. If your server expects a raw stream (e.g. `application/octet-stream`), you must explicitly set the `Content-Type` header in `headers`. | 1.0.0 |
216
+
|**`mimeType`**| <code>string</code> | Mime type of the data to upload. Only used if "Content-Type" header was not provided. | 1.0.0 |
217
+
|**`fileKey`**| <code>string</code> | Type of form element. The default is set to "file". Only used if "Content-Type" header was not provided. | 1.0.0 |
218
+
|**`progress`**| <code>boolean</code> | If true, progress event will be dispatched on every chunk received. See addListener() for more information. Chunks are throttled to every 100ms on Android/iOS to avoid slowdowns. Default is `false`. | 1.0.0 |
219
+
|**`method`**| <code>string</code> | The Http Request method to run. (Default is POST) | 1.0.0 |
220
+
|**`params`**| <code><ahref="#httpparams">HttpParams</a></code> | URL parameters to append to the request. This <ahref="#httpparams">`HttpParams`</a> interface comes from `@capacitor/core`. | 1.0.0 |
221
+
|**`headers`**| <code><ahref="#httpheaders">HttpHeaders</a></code> | Http Request headers to send with the request. This <ahref="#httpheaders">`HttpHeaders`</a> interface comes from `@capacitor/core`. | 1.0.0 |
222
+
|**`readTimeout`**| <code>number</code> | How long to wait to read additional data in milliseconds. Resets each time new data is received. Default is 60,000 milliseconds (1 minute). Not supported on web. | 1.0.0 |
223
+
|**`connectTimeout`**| <code>number</code> | How long to wait for the initial connection in milliseconds. Default is 60,000 milliseconds (1 minute). Not supported on web. In iOS, there's no real distinction between `connectTimeout`and `readTimeout`. Plugin tries to use `connectTimeout`, if not uses `readTimeout`, if not uses default | 1.0.0 |
224
+
|**`disableRedirects`**| <code>boolean</code> | Sets whether automatic HTTP redirects should be disabled. Not supported on web. | 1.0.0 |
225
+
|**`shouldEncodeUrlParams`**| <code>boolean</code> | Use this option if you need to keep the URL unencoded in certain cases (already encoded, azure/firebase testing, etc.). The default is `true`. Not supported on web. | 1.0.0 |
0 commit comments