@ammarahmed/react-native-upload 6.16.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.
- package/.circleci/config.yml +15 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +4 -0
- package/.prettierrc.js +6 -0
- package/CHANGELOG.md +3 -0
- package/CONTRIBUTING.md +8 -0
- package/LICENSE +21 -0
- package/README.md +391 -0
- package/android/build.gradle +82 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradle.properties +6 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +390 -0
- package/ios/RNFileUploader.h +8 -0
- package/ios/RNFileUploader.m +457 -0
- package/ios/VydiaRNFileUploader.xcodeproj/project.pbxproj +254 -0
- package/package.json +75 -0
- package/react-native-upload.podspec +18 -0
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
package/.prettierrc.js
ADDED
package/CHANGELOG.md
ADDED
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## Issues
|
|
2
|
+
|
|
3
|
+
Along with a bug report, provide a functional example repository which
|
|
4
|
+
reproduces the bug you're experiencing. We've made this very easy by providing
|
|
5
|
+
a full-stack (React Native + Express.js) example app, which you can fork and
|
|
6
|
+
alter to reproduce your bug:
|
|
7
|
+
|
|
8
|
+
[ReactNativeBackgroundUploadExample](https://github.com/Vydia/ReactNativeBackgroundUploadExample)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Vydia, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
# react-native-background-upload [](https://badge.fury.io/js/react-native-background-upload)   [](https://github.com/semantic-release/semantic-release)
|
|
2
|
+
|
|
3
|
+
The only React Native http post file uploader with android and iOS background support. If you are uploading large files like videos, use this so your users can background your app during a long upload.
|
|
4
|
+
|
|
5
|
+
NOTE: Use major version 4 with RN 47.0 and greater. If you have RN less than 47, use 3.0. To view all available versions:
|
|
6
|
+
`npm show react-native-background-upload versions`
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# Installation
|
|
10
|
+
|
|
11
|
+
## 1. Install package
|
|
12
|
+
|
|
13
|
+
`npm install --save react-native-background-upload`
|
|
14
|
+
|
|
15
|
+
or
|
|
16
|
+
|
|
17
|
+
`yarn add react-native-background-upload`
|
|
18
|
+
|
|
19
|
+
Note: if you are installing on React Native < 0.47, use `react-native-background-upload@3.0.0` instead of `react-native-background-upload`
|
|
20
|
+
|
|
21
|
+
## 2. Link Native Code
|
|
22
|
+
|
|
23
|
+
### Autolinking (React Native >= 0.60)
|
|
24
|
+
|
|
25
|
+
##### iOS
|
|
26
|
+
|
|
27
|
+
`cd ./ios && pod install && cd ../`
|
|
28
|
+
|
|
29
|
+
##### Android
|
|
30
|
+
|
|
31
|
+
No further actions required.
|
|
32
|
+
|
|
33
|
+
### Automatic Native Library Linking (React Native < 0.60)
|
|
34
|
+
|
|
35
|
+
`react-native link react-native-background-upload`
|
|
36
|
+
|
|
37
|
+
### Or, Manually Link It
|
|
38
|
+
|
|
39
|
+
#### iOS
|
|
40
|
+
|
|
41
|
+
1. In the XCode's "Project navigator", right click on your project's Libraries folder ➜ `Add Files to <...>`
|
|
42
|
+
2. Go to `node_modules` ➜ `react-native-background-upload` ➜ `ios` ➜ select `VydiaRNFileUploader.xcodeproj`
|
|
43
|
+
3. Add `VydiaRNFileUploader.a` to `Build Phases -> Link Binary With Libraries`
|
|
44
|
+
|
|
45
|
+
#### Android
|
|
46
|
+
1. Add the following lines to `android/settings.gradle`:
|
|
47
|
+
|
|
48
|
+
```gradle
|
|
49
|
+
include ':react-native-background-upload'
|
|
50
|
+
project(':react-native-background-upload').projectDir = new File(settingsDir, '../node_modules/react-native-background-upload/android')
|
|
51
|
+
```
|
|
52
|
+
2. Add the compile and resolutionStrategy line to the dependencies in `android/app/build.gradle`:
|
|
53
|
+
|
|
54
|
+
```gradle
|
|
55
|
+
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' } // required by react-native-background-upload until React Native supports okhttp >= okhttp 3.5
|
|
56
|
+
|
|
57
|
+
dependencies {
|
|
58
|
+
compile project(':react-native-background-upload')
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
3. Add the import and link the package in `MainApplication.java`:
|
|
64
|
+
|
|
65
|
+
```java
|
|
66
|
+
import com.vydia.RNUploader.UploaderReactPackage; <-- add this import
|
|
67
|
+
|
|
68
|
+
public class MainApplication extends Application implements ReactApplication {
|
|
69
|
+
@Override
|
|
70
|
+
protected List<ReactPackage> getPackages() {
|
|
71
|
+
return Arrays.<ReactPackage>asList(
|
|
72
|
+
new MainReactPackage(),
|
|
73
|
+
new UploaderReactPackage() // <-- add this line
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
4. Ensure Android SDK versions. Open your app's `android/app/build.gradle` file. Ensure `compileSdkVersion` and `targetSdkVersion` are 25. Otherwise you'll get compilation errors.
|
|
80
|
+
|
|
81
|
+
## 3. Expo
|
|
82
|
+
|
|
83
|
+
To use this library with [Expo](https://expo.io) one must first detach (eject) the project and follow [step 2](#2-link-native-code) instructions. Additionally on iOS there is a must to add a Header Search Path to other dependencies which are managed using Pods. To do so one has to add `$(SRCROOT)/../../../ios/Pods/Headers/Public` to Header Search Path in `VydiaRNFileUploader` module using XCode.
|
|
84
|
+
|
|
85
|
+
# Usage
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import Upload from 'react-native-background-upload'
|
|
89
|
+
|
|
90
|
+
const options = {
|
|
91
|
+
url: 'https://myservice.com/path/to/post',
|
|
92
|
+
path: 'file://path/to/file/on/device',
|
|
93
|
+
method: 'POST',
|
|
94
|
+
type: 'raw',
|
|
95
|
+
maxRetries: 2, // set retry count (Android only). Default 2
|
|
96
|
+
headers: {
|
|
97
|
+
'content-type': 'application/octet-stream', // Customize content-type
|
|
98
|
+
'my-custom-header': 's3headervalueorwhateveryouneed'
|
|
99
|
+
},
|
|
100
|
+
// Below are options only supported on Android
|
|
101
|
+
notification: {
|
|
102
|
+
enabled: true
|
|
103
|
+
},
|
|
104
|
+
useUtf8Charset: true
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Upload.startUpload(options).then((uploadId) => {
|
|
108
|
+
console.log('Upload started')
|
|
109
|
+
Upload.addListener('progress', uploadId, (data) => {
|
|
110
|
+
console.log(`Progress: ${data.progress}%`)
|
|
111
|
+
})
|
|
112
|
+
Upload.addListener('error', uploadId, (data) => {
|
|
113
|
+
console.log(`Error: ${data.error}%`)
|
|
114
|
+
})
|
|
115
|
+
Upload.addListener('cancelled', uploadId, (data) => {
|
|
116
|
+
console.log(`Cancelled!`)
|
|
117
|
+
})
|
|
118
|
+
Upload.addListener('completed', uploadId, (data) => {
|
|
119
|
+
// data includes responseCode: number and responseBody: Object
|
|
120
|
+
console.log('Completed!')
|
|
121
|
+
})
|
|
122
|
+
}).catch((err) => {
|
|
123
|
+
console.log('Upload error!', err)
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Multipart Uploads
|
|
128
|
+
|
|
129
|
+
Just set the `type` option to `multipart` and set the `field` option. Example:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
const options = {
|
|
133
|
+
url: 'https://myservice.com/path/to/post',
|
|
134
|
+
path: 'file://path/to/file%20on%20device.png',
|
|
135
|
+
method: 'POST',
|
|
136
|
+
field: 'uploaded_media',
|
|
137
|
+
type: 'multipart'
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Note the `field` property is required for multipart uploads.
|
|
142
|
+
|
|
143
|
+
# API
|
|
144
|
+
|
|
145
|
+
## Top Level Functions
|
|
146
|
+
|
|
147
|
+
All top-level methods are available as named exports or methods on the default export.
|
|
148
|
+
|
|
149
|
+
### startUpload(options)
|
|
150
|
+
|
|
151
|
+
The primary method you will use, this starts the upload process.
|
|
152
|
+
|
|
153
|
+
Returns a promise with the string ID of the upload. Will reject if there is a connection problem, the file doesn't exist, or there is some other problem.
|
|
154
|
+
|
|
155
|
+
`options` is an object with following values:
|
|
156
|
+
|
|
157
|
+
*Note: You must provide valid URIs. react-native-background-upload does not escape the values you provide.*
|
|
158
|
+
|
|
159
|
+
|Name|Type|Required|Default|Description|Example|
|
|
160
|
+
|---|---|---|---|---|---|
|
|
161
|
+
|`url`|string|Required||URL to upload to|`https://myservice.com/path/to/post`|
|
|
162
|
+
|`path`|string|Required||File path on device|`file://something/coming/from%20the%20device.png`|
|
|
163
|
+
|`type`|'raw' or 'multipart'|Optional|`raw`|Primary upload type.||
|
|
164
|
+
|`method`|string|Optional|`POST`|HTTP method||
|
|
165
|
+
|`customUploadId`|string|Optional||`startUpload` returns a Promise that includes the upload ID, which can be used for future status checks. By default, the upload ID is automatically generated. This parameter allows a custom ID to use instead of the default.||
|
|
166
|
+
|`headers`|object|Optional||HTTP headers|`{ 'Accept': 'application/json' }`|
|
|
167
|
+
|`field`|string|Required if `type: 'multipart'`||The form field name for the file. Only used when `type: 'multipart`|`uploaded-file`|
|
|
168
|
+
|`parameters`|object|Optional||Additional form fields to include in the HTTP request. Only used when `type: 'multipart`||
|
|
169
|
+
|`notification`|Notification object (see below)|Optional||Android only. |`{ enabled: true, onProgressTitle: "Uploading...", autoClear: true }`|
|
|
170
|
+
|`useUtf8Charset`|boolean|Optional||Android only. Set to true to use `utf-8` as charset. ||
|
|
171
|
+
|`appGroup`|string|Optional|iOS only. App group ID needed for share extensions to be able to properly call the library. See: https://developer.apple.com/documentation/foundation/nsfilemanager/1412643-containerurlforsecurityapplicati
|
|
172
|
+
|
|
173
|
+
### Notification Object (Android Only)
|
|
174
|
+
|Name|Type|Required|Description|Example|
|
|
175
|
+
|---|---|---|---|---|
|
|
176
|
+
|`enabled`|boolean|Optional|Enable or diasable notifications. Works only on Android version < 8.0 Oreo. On Android versions >= 8.0 Oreo is required by Google's policy to display a notification when a background service run|`{ enabled: true }`|
|
|
177
|
+
|`autoClear`|boolean|Optional|Autoclear notification on complete|`{ autoclear: true }`|
|
|
178
|
+
|`notificationChannel`|string|Optional|Sets android notificaion channel|`{ notificationChannel: "My-Upload-Service" }`|
|
|
179
|
+
|`enableRingTone`|boolean|Optional|Sets whether or not to enable the notification sound when the upload gets completed with success or error|`{ enableRingTone: true }`|
|
|
180
|
+
|`onProgressTitle`|string|Optional|Sets notification progress title|`{ onProgressTitle: "Uploading" }`|
|
|
181
|
+
|`onProgressMessage`|string|Optional|Sets notification progress message|`{ onProgressMessage: "Uploading new video" }`|
|
|
182
|
+
|`onCompleteTitle`|string|Optional|Sets notification complete title|`{ onCompleteTitle: "Upload finished" }`|
|
|
183
|
+
|`onCompleteMessage`|string|Optional|Sets notification complete message|`{ onCompleteMessage: "Your video has been uploaded" }`|
|
|
184
|
+
|`onErrorTitle`|string|Optional|Sets notification error title|`{ onErrorTitle: "Upload error" }`|
|
|
185
|
+
|`onErrorMessage`|string|Optional|Sets notification error message|`{ onErrorMessage: "An error occured while uploading a video" }`|
|
|
186
|
+
|`onCancelledTitle`|string|Optional|Sets notification cancelled title|`{ onCancelledTitle: "Upload cancelled" }`|
|
|
187
|
+
|`onCancelledMessage`|string|Optional|Sets notification cancelled message|`{ onCancelledMessage: "Video upload was cancelled" }`|
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
### getFileInfo(path)
|
|
191
|
+
|
|
192
|
+
Returns some useful information about the file in question. Useful if you want to set a MIME type header.
|
|
193
|
+
|
|
194
|
+
`path` is a string, such as `file://path.to.the.file.png`
|
|
195
|
+
|
|
196
|
+
Returns a Promise that resolves to an object containing:
|
|
197
|
+
|
|
198
|
+
|Name|Type|Required|Description|Example|
|
|
199
|
+
|---|---|---|---|---|
|
|
200
|
+
|`name`|string|Required|The file name within its directory.|`image2.png`|
|
|
201
|
+
|`exists`|boolean|Required|Is there a file matching this path?||
|
|
202
|
+
|`size`|number|If `exists`|File size, in bytes||
|
|
203
|
+
|`extension`|string|If `exists`|File extension|`mov`|
|
|
204
|
+
|`mimeType`|string|If `exists`|The MIME type for the file.|`video/mp4`|
|
|
205
|
+
|
|
206
|
+
### cancelUpload(uploadId)
|
|
207
|
+
|
|
208
|
+
Cancels an upload.
|
|
209
|
+
|
|
210
|
+
`uploadId` is the result of the Promise returned from `startUpload`
|
|
211
|
+
|
|
212
|
+
Returns a Promise that resolves to an boolean indicating whether the upload was cancelled.
|
|
213
|
+
|
|
214
|
+
### addListener(eventType, uploadId, listener)
|
|
215
|
+
|
|
216
|
+
Adds an event listener, possibly confined to a single upload.
|
|
217
|
+
|
|
218
|
+
`eventType` Event to listen for. Values: 'progress' | 'error' | 'completed' | 'cancelled'
|
|
219
|
+
|
|
220
|
+
`uploadId` The upload ID from `startUpload` to filter events for. If null, this will include all uploads.
|
|
221
|
+
|
|
222
|
+
`listener` Function to call when the event occurs.
|
|
223
|
+
|
|
224
|
+
Returns an [EventSubscription](https://github.com/facebook/react-native/blob/master/Libraries/vendor/emitter/EmitterSubscription.js). To remove the listener, call `remove()` on the `EventSubscription`.
|
|
225
|
+
|
|
226
|
+
### shouldLimitNetwork(limit)
|
|
227
|
+
|
|
228
|
+
`limit` boolean, sets whether or not to limit network usage.
|
|
229
|
+
|
|
230
|
+
On Android, this setting takes effect immediately and will be applied for the next upload. On iOS, this setting will be only applied for the next NSURLSession.
|
|
231
|
+
|
|
232
|
+
### getAllUploads()
|
|
233
|
+
|
|
234
|
+
Retrieves all scheduled uploads and their state from system's internal database.
|
|
235
|
+
|
|
236
|
+
Note that this will not give you all the uploads ever scheduled, both iOS and Android periodically prune completed(succeeded/failed/cancelled) tasks from their database. Therefore this should not be used as the primary way to check upload statuses, add your listeners via `addListener` instead. However, `getAllUploads` is particularly useful as a backup plan in case events were dropped(e.g. adding listeners too late).
|
|
237
|
+
|
|
238
|
+
Returns a Promise that resolves to an array of objects containing:
|
|
239
|
+
|
|
240
|
+
|Name|Type|Required|Description|
|
|
241
|
+
|---|---|---|---|
|
|
242
|
+
|`id`|string|Required|The upload ID from `startUpload`|
|
|
243
|
+
|`state`|[UploadState](#uploadstate)|Required|The current state of the upload|
|
|
244
|
+
|
|
245
|
+
## Events
|
|
246
|
+
|
|
247
|
+
### progress
|
|
248
|
+
|
|
249
|
+
Event Data
|
|
250
|
+
|
|
251
|
+
|Name|Type|Required|Description|
|
|
252
|
+
|---|---|---|---|
|
|
253
|
+
|`id`|string|Required|The ID of the upload.|
|
|
254
|
+
|`progress`|0-100|Required|Percentage completed.|
|
|
255
|
+
|
|
256
|
+
### error
|
|
257
|
+
|
|
258
|
+
Event Data
|
|
259
|
+
|
|
260
|
+
|Name|Type|Required|Description|
|
|
261
|
+
|---|---|---|---|
|
|
262
|
+
|`id`|string|Required|The ID of the upload.|
|
|
263
|
+
|`error`|string|Required|Error message.|
|
|
264
|
+
|
|
265
|
+
### completed
|
|
266
|
+
|
|
267
|
+
Event Data
|
|
268
|
+
|
|
269
|
+
|Name|Type|Required|Description|
|
|
270
|
+
|---|---|---|---|
|
|
271
|
+
|`id`|string|Required|The ID of the upload.|
|
|
272
|
+
|`responseCode`|string|Required|HTTP status code received|
|
|
273
|
+
|`responseBody`|string|Required|HTTP response body|
|
|
274
|
+
|
|
275
|
+
### cancelled
|
|
276
|
+
|
|
277
|
+
Event Data
|
|
278
|
+
|
|
279
|
+
|Name|Type|Required|Description|
|
|
280
|
+
|---|---|---|---|
|
|
281
|
+
|`id`|string|Required|The ID of the upload.|
|
|
282
|
+
|
|
283
|
+
## Types
|
|
284
|
+
|
|
285
|
+
### UploadState
|
|
286
|
+
|
|
287
|
+
|Value|Description|
|
|
288
|
+
|---|---|
|
|
289
|
+
|`cancelled`|The upload has been cancelled, either by OS or by using `cancelUpload`|
|
|
290
|
+
|`completed`|The upload has finished, either succeeded or failed|
|
|
291
|
+
|`pending`|The upload is scheduled but not active at the moment|
|
|
292
|
+
|`running`|The upload is in progress|
|
|
293
|
+
|
|
294
|
+
# Customizing Android Build Properties
|
|
295
|
+
You may want to customize the `compileSdk, buildToolsVersion, and targetSdkVersion` versions used by this package. For that, add this to `android/build.gradle`:
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
ext {
|
|
299
|
+
targetSdkVersion = 23
|
|
300
|
+
compileSdkVersion = 23
|
|
301
|
+
buildToolsVersion = '23.0.2'
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Add it above `allProjects` and you're good. Your `android/build.gradle` might then resemble:
|
|
306
|
+
```
|
|
307
|
+
buildscript {
|
|
308
|
+
repositories {
|
|
309
|
+
jcenter()
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
ext {
|
|
314
|
+
targetSdkVersion = 27
|
|
315
|
+
compileSdkVersion = 27
|
|
316
|
+
buildToolsVersion = '23.0.2'
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
allprojects {
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
# FAQs
|
|
324
|
+
|
|
325
|
+
Is there an example/sandbox app to test out this package?
|
|
326
|
+
|
|
327
|
+
> Yes, there is a simple react native app that comes with an [express](https://github.com/expressjs/express) server where you can see react-native-background-upload in action and try things out in an isolated local environment.
|
|
328
|
+
|
|
329
|
+
[RNBackgroundExample](https://github.com/Vydia/react-native-background-upload/blob/master/example/RNBackgroundExample)
|
|
330
|
+
|
|
331
|
+
Does it support iOS camera roll assets?
|
|
332
|
+
|
|
333
|
+
> Yes, as of version 4.3.0.
|
|
334
|
+
|
|
335
|
+
Does it support multiple file uploads?
|
|
336
|
+
|
|
337
|
+
> Yes and No. It supports multiple concurrent uploads, but only a single upload per request. That should be fine for 90%+ of cases.
|
|
338
|
+
|
|
339
|
+
Why should I use this file uploader instead of others that I've Googled like [react-native-uploader](https://github.com/aroth/react-native-uploader)?
|
|
340
|
+
|
|
341
|
+
> This package has two killer features not found anywhere else (as of 12/16/2016). First, it works on both iOS and Android. Others are iOS only. Second, it supports background uploading. This means that users can background your app and the upload will continue. This does not happen with other uploaders.
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
# Contributing
|
|
345
|
+
|
|
346
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
347
|
+
|
|
348
|
+
# Common Issues
|
|
349
|
+
|
|
350
|
+
## BREAKING CHANGE IN 3.0
|
|
351
|
+
This is for 3.0 only. This does NOT apply to 4.0, as recent React Native versions have upgraded the `okhttp` dependencies. Anyway...
|
|
352
|
+
|
|
353
|
+
In 3.0, you need to add
|
|
354
|
+
```gradle
|
|
355
|
+
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }
|
|
356
|
+
```
|
|
357
|
+
to your app's app's `android/app/build.gradle` file.
|
|
358
|
+
|
|
359
|
+
Just add it above (not within) `dependencies` and you'll be fine.
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
## BREAKING CHANGE IN 2.0
|
|
363
|
+
Two big things happened in version 2.0. First, thehe Android package name had to be changed, as it conflicted with our own internal app. My bad. Second, we updated the android upload service dependency to the latest, but that requires the app have a compileSdkVersion and targetSdkVersion or 25.
|
|
364
|
+
|
|
365
|
+
To upgrade:
|
|
366
|
+
In `MainApplication.java`:
|
|
367
|
+
|
|
368
|
+
Change
|
|
369
|
+
|
|
370
|
+
```java
|
|
371
|
+
import com.vydia.UploaderReactPackage;
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
to
|
|
375
|
+
|
|
376
|
+
```java
|
|
377
|
+
import com.vydia.RNUploader.UploaderReactPackage;
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Then open your app's `android/app/build.gradle` file.
|
|
381
|
+
Ensure `compileSdkVersion` and `targetSdkVersion` are 25.
|
|
382
|
+
|
|
383
|
+
Done!
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
## Gratitude
|
|
387
|
+
|
|
388
|
+
Thanks to:
|
|
389
|
+
- [android-upload-service](https://github.com/gotev/android-upload-service) It made Android dead simple to support.
|
|
390
|
+
|
|
391
|
+
- [MIME type from path on iOS](http://stackoverflow.com/questions/2439020/wheres-the-iphone-mime-type-database) Thanks for the answer!
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext {
|
|
3
|
+
agpVersion = '7.4.0'
|
|
4
|
+
kotlinVersion = '1.9.22'
|
|
5
|
+
buildToolsVersion = '34.0.0'
|
|
6
|
+
compileSdkVersion = 34
|
|
7
|
+
targetSdkVersion = 29
|
|
8
|
+
minSdkVersion = 18
|
|
9
|
+
}
|
|
10
|
+
ext.detoxKotlinVersion = ext.kotlinVersion
|
|
11
|
+
|
|
12
|
+
repositories {
|
|
13
|
+
mavenCentral()
|
|
14
|
+
google()
|
|
15
|
+
}
|
|
16
|
+
dependencies {
|
|
17
|
+
classpath "com.android.tools.build:gradle:$agpVersion"
|
|
18
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
apply plugin: 'com.android.library'
|
|
23
|
+
apply plugin: 'kotlin-android'
|
|
24
|
+
|
|
25
|
+
def DEFAULT_COMPILE_SDK_VERSION = 31
|
|
26
|
+
def DEFAULT_BUILD_TOOLS_VERSION = "30.0.2"
|
|
27
|
+
def DEFAULT_TARGET_SDK_VERSION = 29
|
|
28
|
+
|
|
29
|
+
def safeExtGet(prop, fallback) {
|
|
30
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
android {
|
|
34
|
+
namespace "com.appfolio.uploader"
|
|
35
|
+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
36
|
+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
37
|
+
|
|
38
|
+
defaultConfig {
|
|
39
|
+
minSdkVersion 21
|
|
40
|
+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
|
|
41
|
+
versionCode 1
|
|
42
|
+
versionName "1.0"
|
|
43
|
+
ndk {
|
|
44
|
+
abiFilters "armeabi-v7a", "x86"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
lintOptions {
|
|
48
|
+
abortOnError false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
repositories {
|
|
53
|
+
mavenCentral()
|
|
54
|
+
google()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
def _ext = ext
|
|
58
|
+
|
|
59
|
+
def _kotlinVersion = _ext.has('detoxKotlinVersion') ? _ext.detoxKotlinVersion : '1.3.10'
|
|
60
|
+
def _kotlinStdlib = _ext.has('detoxKotlinStdlib') ? _ext.detoxKotlinStdlib : 'kotlin-stdlib-jdk8'
|
|
61
|
+
|
|
62
|
+
dependencies {
|
|
63
|
+
def work_version = "2.9.0"
|
|
64
|
+
|
|
65
|
+
implementation "androidx.work:work-runtime:$work_version"
|
|
66
|
+
implementation "androidx.work:work-runtime-ktx:$work_version"
|
|
67
|
+
|
|
68
|
+
implementation "androidx.core:core-ktx:1.12.0"
|
|
69
|
+
|
|
70
|
+
//noinspection GradleDynamicVersion
|
|
71
|
+
implementation 'com.facebook.react:react-native:+'
|
|
72
|
+
|
|
73
|
+
implementation "org.jetbrains.kotlin:$_kotlinStdlib:$_kotlinVersion"
|
|
74
|
+
|
|
75
|
+
//noinspection GradleDependency
|
|
76
|
+
implementation 'net.gotev:uploadservice:4.9.4'
|
|
77
|
+
//noinspection GradleDependency
|
|
78
|
+
implementation 'net.gotev:uploadservice-okhttp:4.9.4'
|
|
79
|
+
|
|
80
|
+
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
|
81
|
+
implementation 'com.google.code.gson:gson:2.10.1'
|
|
82
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Project-wide Gradle settings.
|
|
2
|
+
|
|
3
|
+
# AndroidX package structure to make it clearer which packages are bundled with the
|
|
4
|
+
# Android operating system, and which are packaged with your app's APK
|
|
5
|
+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
|
6
|
+
android.useAndroidX=true
|