Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
d16e2b6
added new behaviors, code format fix
thomasttvo Jun 3, 2022
1d2e5bb
unused imports
thomasttvo Jun 3, 2022
325686c
proper typescript setup
thomasttvo Jun 3, 2022
b33c637
added `chunkFile`
thomasttvo Jun 3, 2022
b8c5770
fixed built types
thomasttvo Jun 4, 2022
10c196f
minor fix
thomasttvo Jun 6, 2022
2512ead
added server side
thomasttvo Jun 7, 2022
7a4dda1
removed incorrect build files
thomasttvo Jun 7, 2022
4a7d630
getUploadStatus
thomasttvo Jun 7, 2022
6c12c02
fix linter
thomasttvo Jun 7, 2022
260ca2c
fix/upgrade linter
thomasttvo Jun 7, 2022
888cbcf
simplified
thomasttvo Jun 8, 2022
2d57bf4
fixed a bug with getUploadStatus
thomasttvo Jun 9, 2022
a2ade4c
better error handling
thomasttvo Jun 9, 2022
a14e507
better error handling
thomasttvo Jun 15, 2022
4dfd48e
md5 the file
thomasttvo Jun 21, 2022
ae821a8
Fixed isDiscretionary being always YES. Made non-discretionary sessio…
thomasttvo Jun 22, 2022
d60c7a9
fix android upload not working
thomasttvo Jul 11, 2022
9fd0da6
Android chunkFile
thomasttvo Jul 12, 2022
7f72b20
minor fix
thomasttvo Jul 12, 2022
2fc6167
cancelled event not working
thomasttvo Jul 12, 2022
755ab9d
fixed cannot sync gradle on M1
thomasttvo Jul 13, 2022
0131c4f
directly link to local android module
thomasttvo Jul 13, 2022
6e137c4
fixed listeners not attached when JS reloads
thomasttvo Jul 13, 2022
0fbc93a
isDiscretionary works on android
thomasttvo Jul 15, 2022
9d3c3ae
upload 1 chunk at a time
thomasttvo Jul 15, 2022
612e332
fix maxRetries not available
thomasttvo Jul 15, 2022
a31b61f
organize
thomasttvo Aug 16, 2022
af7c89c
organize
thomasttvo Aug 17, 2022
2c52ab3
organize
thomasttvo Aug 17, 2022
aa8d111
ability to cancel uploads if network conditions no longer apply
thomasttvo Aug 17, 2022
9dece90
doc
thomasttvo Aug 17, 2022
c17d193
naming changes
thomasttvo Aug 17, 2022
89e8f31
semantics
thomasttvo Aug 17, 2022
b5fedc2
no more getFileInfo
thomasttvo Aug 17, 2022
6a95ba6
added missing initialization
thomasttvo Aug 18, 2022
6f3d33b
smart network handling
thomasttvo Aug 19, 2022
c90a29f
small changes
thomasttvo Aug 19, 2022
a1241d4
update gradle
thomasttvo Aug 19, 2022
0d1c260
small fix
thomasttvo Aug 19, 2022
a1aeac4
minor changes
thomasttvo Aug 19, 2022
0acad2a
simplify NetworkResolution.kt
thomasttvo Aug 19, 2022
274c0f4
fix connection not made
thomasttvo Aug 20, 2022
f00d64d
add a method to make it smart network resolution optional
thomasttvo Aug 22, 2022
a2262a2
removed unused
thomasttvo Nov 11, 2022
a20056d
removed smart network resolution as it confuses react-native's fetch
thomasttvo Nov 11, 2022
2401b8e
Restore used function in ios/VydiaRNFileUploader.m
elliottkember Nov 16, 2022
4bd9f8a
Merge pull request #1 from openspacelabs/next-gen
thomasttvo Nov 16, 2022
c9230d3
v6.6.0
elliottkember Nov 16, 2022
872cacd
fix coroutine usage and offload chunk calculation to client
thomasttvo Nov 16, 2022
6f026de
Restore used function in ios/VydiaRNFileUploader.m
elliottkember Nov 16, 2022
7cb2a65
Merge remote-tracking branch 'origin/master' into thomas/offload-chun…
thomasttvo Nov 17, 2022
e24bd1a
fix chunkPath, improved error logging
thomasttvo Nov 17, 2022
7984757
bump version
thomasttvo Nov 21, 2022
7846f53
Merge pull request #2 from openspacelabs/thomas/offload-chunk-calcula…
elliottkember Nov 23, 2022
e7d0d0d
iOS only
Mar 28, 2023
419a054
java
Mar 28, 2023
4d5c54a
isWififOnly -> wifiOnly
Mar 28, 2023
a684a91
Remove autocreated file
Mar 29, 2023
f802306
wifiUrlSession
Mar 29, 2023
65f35a1
Version bump
Mar 29, 2023
bf89b5e
Fix for discretionary
Mar 30, 2023
df24bfd
Merge pull request #3 from openspacelabs/elliott/discretionary-change…
elliottkember Apr 4, 2023
99b5d5a
ENG-14121 Android Worker (#4)
thomasttvo May 8, 2023
e2bc3c8
ENG-15361 Android Fixes (#5)
thomasttvo May 18, 2023
54ab7ac
Removed kotlin-android-extensions
AceNorth Jun 8, 2023
1e71b04
added comment
AceNorth Jun 8, 2023
05aeb72
Merge pull request #6 from openspacelabs/andy/removeDeprecatedKotlinLib
AceNorth Jun 8, 2023
29ef5a4
Fix "cancelled" emitted when an upload with the same ID is started (#7)
thomasttvo Oct 26, 2023
4ce3d88
bump
thomasttvo Oct 26, 2023
4ae0ba3
Fix generated type missing `undefined` in the union (#8)
thomasttvo Nov 13, 2023
4c3f4ef
sync kotlin and java version to 17
louis-openspace Feb 21, 2024
a4315d4
bump semver
louis-openspace Feb 27, 2024
df00071
Merge pull request #9 from openspacelabs/fix-kotlin-ver
louis-openspace Feb 27, 2024
f047dc9
fix
thomasttvo Mar 7, 2024
9594ecb
fix
thomasttvo Mar 7, 2024
572a929
fix
thomasttvo Mar 7, 2024
f296ecf
bump
thomasttvo Mar 7, 2024
e36adae
no longer require client to modify manifest
thomasttvo Mar 7, 2024
8f41527
Merge pull request #10 from openspacelabs/thomas/fix-upload-io-error
thomasttvo Mar 7, 2024
9c01e25
Update README.md
thomasttvo Aug 7, 2024
fd3cfd1
fix buildˆ
Sep 19, 2024
f8d5ac3
test server
Sep 19, 2024
2b7fc8e
Rename .java to .kt
Sep 19, 2024
e6b92d9
RN 0.75
Sep 20, 2024
e6123cd
functioning example
Sep 20, 2024
c965c5d
lock file
Sep 20, 2024
81f73d7
node
Sep 20, 2024
85e1aa7
Merge pull request #11 from openspacelabs/thomas/form-data
thomasttvo Sep 21, 2024
6a48204
fix
Sep 24, 2024
61d95f7
Merge pull request #13 from openspacelabs/thomas/fix-js-reload-crash
thomasttvo Sep 24, 2024
e6b3711
v7.5.2
Sep 24, 2024
53cf79d
Form data test case in example app (#12)
thomasttvo Feb 3, 2025
eebaf0e
Upgrade androidx.work:work-runtime-ktx:2.7.1 -> 2.8.1 (#15)
thomasttvo Oct 3, 2025
418123c
RN0.77 kotlin syntax
elliottkember Oct 12, 2025
fe18031
removed (#16)
thomasttvo Oct 13, 2025
4317330
Some small improvements for the example app (#14)
thomasttvo Oct 13, 2025
c33c68f
Remove chunks
elliottkember Oct 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
example/RNBackgroundExample/node_modules
example/RNBackgroundExample/e2e
example/
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
root: true,
extends: '@react-native-community',
extends: '@react-native',
plugins: ['unused-imports'],
rules: {
'unused-imports/no-unused-imports': 'error',
},
};
67 changes: 0 additions & 67 deletions .github/workflows/android.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/deploy-release.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/iOS.yml

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ jobs:
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 20

- name: install node_modules
run: yarn install --frozen-lockfile
run: |
yarn install --frozen-lockfile
yarn --cwd example/RNBGUExample install --frozen-lockfile

- name: node lint
run:
Expand Down
330 changes: 91 additions & 239 deletions README.md

Large diffs are not rendered by default.

35 changes: 27 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
ext {
kotlinVersion = '1.4.0'
kotlinVersion = '1.6.20'
buildToolsVersion = '29.0.2'
compileSdkVersion = 29
compileSdkVersion = 31 // this helps us use the latest Worker version
targetSdkVersion = 29
minSdkVersion = 18
}
Expand All @@ -13,14 +13,13 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
Expand All @@ -31,11 +30,18 @@ def safeExtGet(prop, fallback) {
}

android {
buildFeatures {
/*
This is a replacement for the deprecated 'kotlin-android-extensions' library. More
information can be found here: https://developer.android.com/topic/libraries/view-binding/migration
*/
viewBinding = true
}
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)

defaultConfig {
minSdkVersion 21
minSdkVersion 24
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
Expand All @@ -46,6 +52,13 @@ android {
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
}

repositories {
Expand All @@ -58,13 +71,19 @@ def _kotlinVersion = _ext.has('detoxKotlinVersion') ? _ext.detoxKotlinVersion :
def _kotlinStdlib = _ext.has('detoxKotlinStdlib') ? _ext.detoxKotlinStdlib : 'kotlin-stdlib-jdk8'

dependencies {
implementation "androidx.core:core-ktx:1.0.1"
implementation "androidx.core:core-ktx:1.7.0"

implementation 'com.facebook.react:react-native:+'

implementation "org.jetbrains.kotlin:$_kotlinStdlib:$_kotlinVersion"

implementation 'net.gotev:uploadservice-okhttp:4.7.0'
implementation("com.squareup.okhttp3:okhttp:4.10.0")

implementation 'com.google.code.gson:gson:2.8.9'

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
implementation "androidx.work:work-runtime-ktx:2.8.1"
}
14 changes: 13 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vydia.RNUploader">
xmlns:tools="http://schemas.android.com/tools"
package="com.vydia.RNUploader">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<application>
<receiver android:name=".NotificationReceiver" />
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
tools:node="merge" />
</application>
</manifest>
67 changes: 67 additions & 0 deletions android/src/main/java/com/vydia/RNUploader/EventReporter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.vydia.RNUploader

import android.util.Log
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import okhttp3.Response

// Sends events to React Native
class EventReporter {
companion object {
private const val TAG = "UploadReceiver"
fun cancelled(uploadId: String) =
sendEvent("cancelled", Arguments.createMap().apply {
putString("id", uploadId)
})

fun error(uploadId: String, exception: Throwable) =
sendEvent("error", Arguments.createMap().apply {
putString("id", uploadId)
putString("error", exception.message ?: "Unknown exception")
})

fun success(uploadId: String, response: Response) =
CoroutineScope(Dispatchers.IO).launch {
sendEvent("completed", Arguments.createMap().apply {
putString("id", uploadId)
putInt("responseCode", response.code)
putString("responseBody", response.body?.string().let {
if (it.isNullOrBlank()) response.message else it
})
putMap("responseHeaders", Arguments.createMap().apply {
response.headers.names().forEach { name ->
putString(name, response.headers.values(name).joinToString(", "))
}
})
})
}

fun progress(uploadId: String, bytesSentTotal: Long, contentLength: Long) =
sendEvent("progress", Arguments.createMap().apply {
putString("id", uploadId)
putDouble("progress", (bytesSentTotal.toDouble() * 100 / contentLength)) //0-100
})

fun notification() = sendEvent("notification")

/** Sends an event to the JS module */
private fun sendEvent(eventName: String, params: WritableMap = Arguments.createMap()) {
val reactContext = UploaderModule.reactContext ?: return

// Right after JS reloads, react instance might not be available yet
if (!reactContext.hasActiveReactInstance()) return

try {
val jsModule = reactContext.getJSModule(RCTDeviceEventEmitter::class.java)
jsModule.emit("RNFileUploader-$eventName", params)
} catch (exc: Throwable) {
Log.e(TAG, "sendEvent() failed", exc)
}
}
}

}
Loading