Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLIBZ-2452: NativeScript Android File Uploads throw and Error #300

Merged
merged 7 commits into from
May 31, 2018

Conversation

thomasconner
Copy link
Contributor

Description

Uploading a file with a NativeScript Android application using the kinvey-nativescript-sdk

Kinvey.Files.upload(filePath, { 'mimeType': 'text/plain' })

would throw the following error:

Error: com.tns.NativeScriptException: Failed to find module: "/./file-upload-worker", relative to: app/tns_modules/kinvey-nativescript-sdk//
JS:       com.tns.Module.resolvePathHelper(Module.java:146)
JS:       com.tns.Module.resolvePath(Module.java:55)
JS:       com.tns.Runtime.callJSMethodNative(Native Method)
JS:       com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
JS:       com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
JS:       com.tns.Runtime.callJSMethod(Runtime.java:957)
JS:       com.tns.Runtime.callJSMethod(Runtime.java:941)
JS:       com.tns.Runtime.callJSMethod(Runtime.java:933)
JS:       com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
JS:       android.os.Handler.handleCallback(Handler.java:790)
JS:       android.os.Handler.dispatchMessage(Handler.java:99)
JS:       android.os.Looper.loop(Looper.java:164)
JS:       android.app.ActivityThread.main(ActivityThread.java:6494)
JS:       java.lang.reflect.Method.invoke(Native Method)
JS:       com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
JS:       com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
JS:       at t.e._initializeWorker (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:467571)
JS:       at t.e.postMessage (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:467315)
JS:       at t.upload (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:466773)
JS:       at r.makeUploadRequest (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:465705)
JS:       at r.e (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:210097)
JS:       at file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:208609
JS:       at J (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:10470)
JS:       at X (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:10591)
JS:       at $ (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:10356)
JS:       at E (file:///data/data/org.nativescript.TestAp/files/app/tns_modules/kinvey-nativescript-sdk/kinvey-nativescript-sdk.js:8:8190)

Changes

  • Use file-loader to import the file upload worker script path.

Tests

  • Manually tested.

We have existing integration tests that test file uploads using a NativeScript Android application. Not sure why this was not failing. I need to discuss with QA team.

@thomasconner thomasconner self-assigned this May 25, 2018
@vinaygahlawat
Copy link
Contributor

Is the root cause of this issue known? Why did using file-loader fix this issue?

@thomasconner
Copy link
Contributor Author

You need to pass a file path to create a worker. There did not exist a file at the path provided because the project is bundled with Webpack. File-loader includes the file correctly so that the file is loaded when provided the file path.

@vinaygahlawat
Copy link
Contributor

vinaygahlawat commented May 31, 2018

Ok, sounds like maybe there is something different in the configuration for the integrated tests. Would be good to know how that was passing, but other than that LGTM.

@vinaygahlawat vinaygahlawat self-requested a review May 31, 2018 17:57
@thomasconner thomasconner merged commit cbdedbe into master May 31, 2018
@thomasconner thomasconner deleted the MLIBZ-2452 branch May 31, 2018 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants