Giter Site home page Giter Site logo

spoonconsulting / cordova-plugin-background-upload Goto Github PK

View Code? Open in Web Editor NEW
50.0 8.0 53.0 36.01 MB

Cordova plugin for background upload

License: Apache License 2.0

Java 58.20% Objective-C 19.94% JavaScript 21.13% Shell 0.73%
cordova android ios plugin background uploads upload-files

cordova-plugin-background-upload's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-background-upload's Issues

Unknown error in Android 10

Used to work just fine, but now identical code always returns the following in my error handler

{id: "20200415_210326.mp4", error: "upload failed"}

Followed by

{id: "20200415_210326.mp4", error: "execute failed", state: "FAILED"}

These are the parameters I pass into the startUpload method:


"settings": {
"filePath": "file:///storage/emulated/0/DCIM/Camera/20200415_210326.mp4"
"id": "20200415_210326.mp4"
"parameters": {
      "Content-Type": "multipart/form-data"
      "X-amz-algorithm": "AWS4-HMAC-SHA256"
      "X-amz-credential": "omitted"
      "X-amz-date": "20200505T225904Z"
      "X-amz-signature": "omitted"
      "acl": "private"
      "key": "216781588719190015_${filename}"
      "policy": "omitted"
      "success_action_status": "201"
   }
"serverUrl": "https://s3.amazonaws.com/mybucket"
}

Running android 10 on a Samsung Galaxy s10+

I'm wondering if it has to do with this: https://stackoverflow.com/a/58934803/2093658

EDIT: After digging in and trying to do a file upload with the regular cordova plugin, i found that using the same uri that this plugin uses results in a "permissions error" This is most likely to do with android 10 scoped storage.

App crashes on window.location.reload or window.location.href='index.html'

When I reload my app from a code update in the JS world, I have been doing window.location.href='index.html', the problem with this is that it seems ios crashes when it tries to rebind/re-init FileTransferManager.init(). My guess is that this can only be bound once...but it would loose reference in the JS world when the window is reloaded. Is there an unbind command or would it be possible to unbind, like FileTransferManager.destroy() so it can be re-inited on a JS/window reload

dependency android-storage no longer available

When trying to install the plugin I'm getting the following error:

       > Could not find com.sromku:simple-storage:1.2.0.
         Searched in the following locations:
           - https://dl.google.com/dl/android/maven2/com/sromku/simple-storage/1.2.0/simple-storage-1.2.0.pom
           - https://repo.maven.apache.org/maven2/com/sromku/simple-storage/1.2.0/simple-storage-1.2.0.pom
         Required by:
             project :app

The package com.sromku:simple-storage is in fact no longer available as it was hosted on the repository jcenter which no longer exists (https://mvnrepository.com/artifact/com.sromku/simple-storage).

Next version requirments

  • Some library need to be started when the application start (SugarORM and gotev upload lib) This is not a cordova plugin best practice and creates a few crash. We would like to remove this startup requirement. We think we should replace the two libraries with native code.
  • We need the plugin to gracefully update (SugarORM has an Sqlite database to store the pending uploads) and an update should at best keep the upload at least cancel them (so they can be retried by the app)
  • The ci is currently not working, we want a CI setuped and working with a provider (travis or circle ci)
  • The plugin should create a fully independent service that can be restarted and will fully manage the upload. (Some android devices restart automatically the service (without the app) when the device is restarted.
  • The javascript api must stay unchanged. (If a change is required it need to be discussed)
  • IOS version of the plugin should not be touched

We might want to investigate : Android Work Manager:

https://developer.android.com/topic/libraries/architecture/workmanager
https://medium.com/androiddevelopers/introducing-workmanager-2083bcfc4712
gotev/android-upload-service#569

File not Found error on android

Hi,

I am using this plugin and it is working perfectly fine. The only scenario where it is failing is when i am trying to upload the images from Android Gallery. I am using cordova-plugin-telerik-imagepicker plugin to pick multiple images from the gallery and when i pass on all the images to upload to server i am getting upload error saying the file does not exist.

Thanks

Need help for using plugin along with Multer

Trying to use the Cordova-plugin-background-upload plugin along with Multer on the server side. The key in the Multer is defined as "XNAME", how can I configure the payload in order to use it properly. I am using the plugin for the Ionic 3 app. The current payload looks like the following as suggested in the documentation of the plugin.

var payload = {
id: filename,
filePath: targetPath,
serverUrl: url,
api_key: "XNAME",
fileKey: "XNAME",
headers: {
mimeType: "image/jpeg",
'Content-Type': 'multipart/form-data'
},
"parameters": {
signature: "mysign",
timestamp: new Date().getTime()
}

Getting the following error message on the Nodejs server:

Unexpected field (err.code=LIMIT_UNEXPECTED_FILE)
Error: Unexpected field

Thanks
-Amit

Finished all uploads on an foreach async

Hi!

var uploader = FileTransferManager.init();  
forEachAsync(photos,function(ctx){
    uploader.on('success', function(upload) {
        db.tbl_photos.where("idp").equals(ctx.item.idp).delete();
        photosSended++;
        if(isOnline()){
            ctx.next()
        }else{
            ctx.stop();
            navigator.notification.alert("Verifique sua conexão e tente novamente.", null, "ERRO");
        }
    });
    var payload = {
        "id": ctx.item.idp,
        "filePath": ctx.item.path.split('?')[0],
        "fileKey": "file",
        "serverUrl": ajax,
        "headers": {
        },
        "parameters": {
            acc: "uploadPhoto",
            idi: ctx.item.idi,
            progress: ctx.item.progress,
            position: ctx.item.position,
            username: username,
            password: password
        }
    };
    
    uploader.startUpload(payload);
    
});

I need a way from know when ALL images were uploaded to show an "alert".

navigator.notification.alert("Todas as imagens foram enviadas.", function(){
    updateInstallations();
}, "Sucesso");

file not found

Tried to get this plugin to work. Til now i used cordova-plugin-file-transfer and this was working. Now by using cordova-plugin-background-upload i get the following error

uploader caught an error: File not found: /storage/emulated/0/Android/data/<app.id>/cache/file.jpg?1518374281044

Any ideas?

Android: initManager was called twice

Error:

2022-02-16 15:37:11.921 25257-25629/com.rocksolidstabilization.dispatch.v2.dev E/PluginManager: Uncaught exception from plugin
    java.lang.IllegalStateException: initManager was called twice
        at com.spoon.backgroundfileupload.FileTransferBackground.initManager(FileTransferBackground.java:158)
        at com.spoon.backgroundfileupload.FileTransferBackground.execute(FileTransferBackground.java:129)
        at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
        at org.apache.cordova.PluginManager.exec(PluginManager.java:146)
        at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
        at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:386)
        at android.os.Looper.loop(Looper.java:169)
        at android.os.HandlerThread.run(HandlerThread.java:65)

So I added break points inside cordova.js the androidExec function and verified it was NOT getting called twice from the browser.

It looks like the error calling the call back deletes the callback from the cordova adapter queue so I cannot get any information after this error even though looking at logcat the error finshes.

Thoughts?

FileTransferManager is not defined when production build

When I build the android app with ionic cordova build android --prod
I install it on device, then appears this error:
Uncaught ReferenceError: FileTransferManager is not defined
at Object.335 (main.js:1)
at e (vendor.js:1)
at window.webpackJsonp (vendor.js:1)
at main.js:1

It seems due to declaration var:
declare var FileTransferManager: any;

Crash on iOS Device

The App crashes on iOS when FileUpload Instance tries to start more then one payload at once.

If only one payload is started or if I wait 10 Secunds until I init the second payload everything works fine.
Uploader is set to {parallelUploadsLimit: 5}

Below I've added the log from XCode.
I verified that the Files are stored and can be accessed.

This is an example file path:
file:///var/mobile/Containers/Data/Application/54190526-4123-40BC-AC1C-80914BF94EEA/Library/files/my_folder/1619733997937.jpg

2021-04-29 18:08:46.639513+0200 GEOPLORE[5587:1210933] will start <FileUpload: 0x28080fc60> {stopped, DA931839-EC8C-435C-9B8C-754F4472DAE8}
2021-04-29 18:08:46.645780+0200 GEOPLORE[5587:1210933] will save mutable info for <FileUpload: 0x28080fc60> {started, DA931839-EC8C-435C-9B8C-754F4472DAE8}
2021-04-29 18:08:46.647102+0200 GEOPLORE[5587:1210933] did start <FileUpload: 0x28080fc60> {started, DA931839-EC8C-435C-9B8C-754F4472DAE8}
2021-04-29 18:08:46.647147+0200 GEOPLORE[5587:1210933] THREAD WARNING: ['FileTransferBackground'] took '89.150879' ms. Plugin should use a background thread.
2021-04-29 18:08:46.647807+0200 GEOPLORE[5587:1210933] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xa14ceb37ed38b2c9
2021-04-29 18:08:46.649332+0200 GEOPLORE[5587:1210933] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xa14ceb37ed38b2c9'
*** First throw call stack:
(0x18d1d3128 0x1a0ee6480 0x18d0e2138 0x18d1d5784 0x18d1d79ac 0x1047bbe4c 0x1047b8e34 0x104948070 0x10494f784 0x104950aac 0x198de0300 0x198fdd0e4 0x199237774 0x199236e58 0x198bdc2ec 0x198f2f8f4 0x198bbe7a4 0x198bbe0b8 0x196c85478 0x196c86270 0x18d152780 0x18d152680 0x18d1519d4 0x18d14bef0 0x18d14b6a8 0x1a37fb570 0x18fa69370 0x18fa6e8ec 0x104655f6c 0x18ce2a140)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xa14ceb37ed38b2c9'
terminating with uncaught exception of type NSException

Success, error event callbacks not fired

When the app is relaunched, the ids of these uploads will be emitted to the error listener.

This is not happening as expected, when I start an upload from an Angular 7 service. Without which I can't detect if or not an upload was done and as such delete the file.

Support for Public Use?

Hi guys, just wondering if you stopped supporting this plugin for public use. Unless there's a strange issue on my end, it doesn't seem like any releases have been published to NPM since v1.1.0 and the addition of this in the plugin.xml makes it not so friendly for use.

<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
    <application android:name="com.orm.SugarApp" />
</edit-config>

It's no big deal if that was the decision made, I just wanted to confirm with you all what your plans were for this plugin since I've been a fan for awhile now. Appreciate it!

Out Of Order Uploads.

We're queuing up a large set of files to be uploaded and need to preserve the order in which they're added. Unfortunately, we're seeing some chunks of the list of items uploaded out of order. For example in a batch of 100 items, the first third would upload in the correct order, then it would choose a random one from later in the list, then it would jump to the last third before finishing up the rest.

Is there any way to strictly enforce the order of a list of items added through startUpload?

Upload directly on S3 (putObject)

Hello,

I am currently trying to upload a video directly to S3 with a signed url retrieved just before ant the put object method.
The video arrives on the S3 bucket concerned, however it arrives corrupted. Indeed when I open the file here is the beginning of its content.

--Boundary+FA062E4EAF6B2732
Content-Disposition: form-data; name="file"; filename="cpcp_video_A997CCE8.mp4"
Content-Type: application/octet-stream

����ftypqt  ����qt  ����wide�$Õ;mdat�–�����-–F9�Çà��_ÃÁäªLv0�21
“ÂMâá˛!ÔE&pêóß#f±+y��Éåëö[��	X≤�=-ôvW9�úùöWD˘Fπ(ÙHdg�ª©'ùöAuÂ⁄§Òzry$c’�Ø<Å™ë%ˇwÎzr„Ÿ)�'�r	¡âë¨�ƒI

The latter seems to have recorded headers making it unreadable. This is my payload :

startUpload FileTransferBackground27120308 ["options": [{
    fileKey ="video";
    filePath = "/var/mobile/Containers/Data/Application/8345F1FC-B31D-44CE-B624-5D51D5173CEC/Library/Caches/cpcp_video_A997CCE8.mp4";
    headers =     {
        "Content-Type" = "video/mp4";
        "x-amz-acl" = private;
    };
    id = "be7bece4-dac4-46bd-898e-017df69733d1";
    notificationTitle = "Uploading files";
    parameters =     {
    };
    requestMethod = PUT;
    serverUrl = serverUrl;
}]]

I am on iOS and this is my package.json versions :

  • "cordova-plugin-background-upload": "git+https://github.com/spoonconsulting/cordova-plugin-background-upload.git#3.0.3",
    
  • "@capacitor/ios": "^3.4.1",
    
  • "@ionic/angular": "^6.0.1",
    

I hope you can help me 💯

Cannot install Plugin on Android

Hello.

I have a problem installing the plugin in my cordova app uses Android and iOS.

On iOS there is no problem on installing the plugin, but on Android i get this Error:

Failed to install 'cordova-plugin-background-upload': Error: cordova-plugin-background-upload cannot be added. <edit-config> changes in this plugin conflicts with <edit-config> changes in config.xml. Conflicts must be resolved before plugin can be added.

config.xml

<platform name="android">
		
		<content src="index.html" />
		<access origin="*" />
		<allow-navigation href="*" />
		<allow-navigation href="http://*/*" />
		<allow-navigation href="https://*/*" />
		<allow-navigation href="data:*" />
		<allow-navigation href="file:*" />
		<allow-navigation href="cdvfile:*" />
		
        <preference name="AndroidLaunchMode" value="singleInstance" />
        <allow-intent href="market:*" />
        <icon density="ldpi" src="res/icon/android/ldpi.png" />
        <icon density="mdpi" src="res/icon/android/mdpi.png" />
        <icon density="hdpi" src="res/icon/android/hdpi.png" />
        <icon density="xhdpi" src="res/icon/android/xhdpi.png" />
        <preference name="AndroidPersistentFileLocation" value="Compatibility" />
        <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,assets,root" />
        <preference name="SplashScreen" value="none" />
        <preference name="loadUrlTimeoutValue" value="700000" />
        <edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
            <!-- The Mobile SDK requires the android:requestLegacyExternalStorage attribute. -->
            <!-- Therefore, you should set the target API level to 29 -->
            <application android:requestLegacyExternalStorage="true"/>
        </edit-config>
        <preference name="android-targetSdkVersion" value="30" />
        <preference name="android-minSdkVersion" value="22" />
    </platform>

But when i removed the <edit-config> tag i get the same erromsg.

"cordova": "^10.0.0",
"cordova-android": "^10.1.1",
"cordova-ios": "^6.2.0",

Abort upload don't work

Hi !
Tried to abort an upload in progress with this

uploader.removeUpload(uploadId, function(e){ console.log("upload aborted",e) }, function(err){ console.log("upload not aborted",err) });

I have the answer "Ok" on e event but it does nothing and the upload normally ends.
Any thoughts ?

upload.serverResponse is a JSON string not parsed on Android

On iOS, the upload serverResponse is a parsed JSON into an object literal, but on Android its an unparsed JSON string.

It results in an inconsistent API that forces me to handle it like that:

// Workaround that Android's response is a JSON string
map(upload =>  
    this.isAndroid
    ? JSON.parse(upload.serverResponse)
    : upload.serverResponse
 )

Unable to build

Have had this plugin working for a while but recently ran into an issue where I cannot get my app to build anymore. I created a fresh app and tried to build with just this plugin and I'm still failing.

Cordova cli version 11.0.0
Android version 10.1.1
Plugin version 2.0.7

Error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find net.gotev:uploadservice:3.5.2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/net/gotev/uploadservice/3.5.2/uploadservice-3.5.2.pom
       - https://repo.maven.apache.org/maven2/net/gotev/uploadservice/3.5.2/uploadservice-3.5.2.pom
     Required by:
         project :app
   > Could not find net.gotev:uploadservice-okhttp:3.5.2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/net/gotev/uploadservice-okhttp/3.5.2/uploadservice-okhttp-3.5.2.pom
       - https://repo.maven.apache.org/maven2/net/gotev/uploadservice-okhttp/3.5.2/uploadservice-okhttp-3.5.2.pom
     Required by:
         project :app
   > Could not find com.sromku:simple-storage:1.2.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/sromku/simple-storage/1.2.0/simple-storage-1.2.0.pom
       - https://repo.maven.apache.org/maven2/com/sromku/simple-storage/1.2.0/simple-storage-1.2.0.pom
     Required by:
         project :app

Package.json

{
  "name": "com.test.app",
  "displayName": "test-app",
  "version": "1.0.0",
  "description": "A sample Apache Cordova application that responds to the deviceready event.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "ecosystem:cordova"
  ],
  "author": "Apache Cordova Team",
  "license": "Apache-2.0",
  "devDependencies": {
    "cordova-android": "^10.1.1",
    "cordova-plugin-androidx": "^1.0.2",
    "cordova-plugin-androidx-adapter": "^1.1.0",
    "cordova-plugin-background-upload": "^1.1.0"
  },
  "cordova": {
    "platforms": [
      "android"
    ],
    "plugins": {
      "cordova-plugin-background-upload": {}
    }
  },
  "dependencies": {}
}

gradle.properties

cdvMinSdkVersion = 30
compileSdkVersion = 30
cdvMinSdkVersion = 30
org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=true
android.enableJetifier=true

Can't seem to get upload to work :(

Hello! Thank you for taking the time to create and update this plugin... I really appreciate it.

I believe I have it setup exactly as shown in the install... but when I run the "startUpload" method, I don't see anything happening at all... no notifications, no network traffic, nothing.

uploader = FileTransferManager.init({parallelUploadsLimit:2},($event)=>{ console.log("this NEVER FIRES"); }); uploader.startUpload(mypayload);

I can't seem to get anything to happen. I'm almost positive I've installed it correctly as I can do a "console.log(FileTransferManager)" and I can see a valid object with properties.... just nothing happens when I call a method.

I'm pretty familiar with cordova plugins but can't seem to get anywhere with this. My current project has 14 other plugins that are all working great.

the UUID for the file... that is something I am suppose to make up correct? As well as the file key?

Thank you for your time.

Failed near end of progress

I'm trying to use this plugin to send two types of files a .txt and a sqlite.db from my android device, the .txt file uploaded sucessfully but the database keeps failing at´94%.
my debug:
uploading: Database progress: 0% uploading: Database progress: 15% uploading: Database progress: 40% uploading: Database progress: 94% upload: Database has failed

my code:
`var uploader = window.util.UPLOADER;

	var payload = {
		"id": 'Database',
		"filePath": dbFilePath,
		"fileKey": "db",
		"serverUrl": window.util.BASE_URL + 'log-upload',
		"headers": {
			"content-type": "application/octet-stream"
		},
		"parameters": {
			"idUsuario": window.util.USER_ID.toString(),
			"idAparelho": device.uuid
		}
	};		
	uploader.startUpload(payload);`

And If I try to send again the process dont start.

NetworkMonitor does not work properly?

Hey,
If i add a File without any connection and then activate cell or wifi, the plugin does not do anything.

For my understanding it should try to upload the file after the network-state changed.
I'm using your plugin with cordova and together with the "cordova-plugin-network-information"-plugin.

Kind regards
Sascha

Show notification with progress

Hi there,
I am using this plugin on ionic app.
How can I show a notification of the upload progress in Android and IOS ?

Thank you.

Android compatibility

Hello, I am trying to use your awesome plugin to upload video on a server from a mobile app.
It actually worked on ios but not in android. I don't know why it isn't working to me. Should I use a different configuration on the payload file for both os ?

Best Regards

Ionic 3 Support

I've been working the last few days on implementing this plugin in Ionic and I have hit a dead end. Is this plugin supported in Ionic 3 and if so are there any examples?

Thank you for your time!

Crash on Android

Hi guys,

I tried to install your plugin first but my app crash after the second request (cordova-plugin-advanced-http) on Android.

I installed it with the command 'cordova plugin add https://github.com/spoonconsulting/cordova-plugin-background-upload.git#2.0.5'

The initialisation (in device-ready event):
image

When my app is launch i can see the initial object :
image

Here's my package.json and my plugin list :
image

image

image

The app crash after 2 request (send with the plugin cordova-plugin-advanced-http)
I didn't use the uploader, i just initialised it in device-ready event
I have no errors.

Can you help me please :) ?

Using plugin with capacitor throws error on androidx.lifecycle

Hi, when i install the plugin with capacitor with the command line
npm install @spoonconsulting/cordova-plugin-background-upload@latest
i get an error after building the app.

Error Msg:

> Task :capacitor-cordova-android-plugins:compileDebugJavaWithJavacwarning: unknown enum constant androidx.lifecycle.Lifecycle$Event.ON_RESUME
 reason: class file for androidx.lifecycle.Lifecycle$Event not found
 warning: unknown enum constant androidx.lifecycle.Lifecycle$Event.ON_PAUSE

android\capacitor-cordova-android-plugins\src\main\java\com\spoon\backgroundfileupload\FileTransferBackground.java:163: error: cannot access androidx.lifecycle.LifecycleObserver
this.globalObserver.register();
^
class file for androidx.lifecycle.LifecycleObserver not found

Package.json
"@spoonconsulting/cordova-plugin-background-upload": "^2.0.7",
"cordova-plugin-androidx": "^3.0.0",
"cordova-plugin-androidx-adapter": "^1.1.3"

Can someone help me with the problem?

Uploads are processed concurrently not only 1 at a time on iOS

The docs says that only 1 concurrent upload is supported at the moment which implies that the plugin queues uploads, while this is true for Android as it does process one upload at a time, I found that on iOS queuing does not occur and all uploads are processed at the same time.

is there something I am missing or that is not the intended behavior?

iOS upload results in PHP upload error UPLOAD_ERR_PARTIAL (3)

Howdy -

I've integrated this plugin into my ionic 3 app and it works great form me on iOS. My boss, however, is consistently running into an upload issue.

The problem: the php upload script is reporting an error, UPLOAD_ERR_PARTIAL, and therefore the bytes of the upload file are unavailable.

To debug this further, I grabbed the demo code you provided and updated the POST URL to a URL that stores a snapshot of $_FILES in a database table.

The demo works perfectly for me. On my boss's iPhone, it appears to work for him. But behind the scenes it's recording:

"post": [],
"get": [],
"files": {
    "file": {
        "name": "cdv_photo_003.jpg",
        "type": "",
        "tmp_name": "",
        **"error": 3,**
        "size": 0
    }
}

This is a fairly consistent issue for him. He does have the occasional successful upload, but the vast majority are error 3's.

I've tried to get more info by using mod_security to log the POST body. Interestingly enough, mod_security reports a HTTP 408 - which is a request timeout, and may explain this issue. Though I don't know enough about mod_security to know if perhaps I just had it configured wrong.

I also ran requests through mitmproxy to analyze them further. When I run them through the proxy, everything works fine. Again, another clue, but not very helpful.

The app is talking to the server via the Amazon Load Balancer. However, when I have the app talk directly to Apache / PHP, I get the same issue.

Years ago, it looks like iOS had an issue with keep-alives and timeouts that would have explained this issue. For example: https://stackoverflow.com/questions/15940549/upload-err-partial-when-uploading-from-ios-to-php-backend

But if I disable keep-alive altogether on the server, it makes no difference.

Here's my ionic environment:

Ionic:

   Ionic CLI          : 5.1.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 2.3.0
   @ionic/app-scripts : 1.2.2

Cordova:

   Cordova CLI       : 8.1.2 ([email protected])
   Cordova Platforms : ios 4.3.1
   Cordova Plugins   : no whitelisted plugins (8 plugins total)

Utility:

   cordova-res : 0.3.0 (update available: 0.5.1)
   native-run  : 0.2.5 (update available: 0.2.6)

System:

   ios-deploy : 1.9.2
   NodeJS     : v8.11.4 (/usr/local/bin/node)
   npm        : 6.9.0
   OS         : macOS Mojave
   Xcode      : Xcode 10.2.1 Build version 10E1001

The server environment is standard AWS LAMP, though as noted, it's behind a EC2 LoadBalancer.

$ httpd -v
Server version: Apache/2.4.39 ()
Server built:   Apr  4 2019 18:09:28

$ php -v
PHP 7.2.16 (cli) (built: Apr  3 2019 18:39:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

$ uname -a
Linux 4.14.88-88.73.amzn2.x86_64 #1 SMP Thu Dec 13 18:04:55 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

My boss appears to be running an up to date system: an iPhone 7 with iOS 12.3.1. View all details

Before I implemented your plugin I was doing a standard HTTP multipart POST to upload files, and that worked fine for my boss.

Finally, my boss' internet connection seems to be relatively slow.

Any idea what could be going on and how to fix it?

Thanks!

iOS : 'AFURLSessionManager.h' file not found in AFNetworking 4.0.1

Hello,

I'm trying to use cordova-plugin-background-upload with Ionic & Capacitor. Npm does not have the latest version. I then add "cordova-plugin-background-upload": "git+https: //github.com/spoonconsulting/cordova-plugin-background-upload.git#2.0.3", to my package.json (the latest stable version according to the readme). Unfortunately I have the following error during the iOS build: 'AFURLSessionManager.h' file not found.

Could someone help me please?

Android Application crash

I have been trying to get this plugin working and after some trail end error I finally managed to get it to start (using the v2-0-0 branch, other branches either simply didn't work or gave random errors during plugin add and/or compile), however now the following problem occurs and the application crashes completely

12-04 18:59:36.680  1441  1441 E AndroidRuntime: java.lang.RuntimeException: Unable to create service net.gotev.uploadservice.UploadService: java.lang.IllegalArgumentException: You have to set namespace to your app package name (context.packageName) in your Application subclass
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4166)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at android.app.ActivityThread.access$1500(ActivityThread.java:268)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1998)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:107)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:237)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7814)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: You have to set namespace to your app package name (context.packageName) in your Application subclass
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at net.gotev.uploadservice.UploadServiceConfig.getNamespace(UploadServiceConfig.kt:74)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at net.gotev.uploadservice.UploadServiceConfig.getBroadcastNotificationAction(UploadServiceConfig.kt:234)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at net.gotev.uploadservice.UploadServiceConfig.getBroadcastNotificationActionIntentFilter(UploadServiceConfig.kt:248)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at net.gotev.uploadservice.observer.request.NotificationActionsObserver.register(NotificationActionsObserver.kt:31)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at net.gotev.uploadservice.UploadService.onCreate(UploadService.kt:193)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4154)
12-04 18:59:36.680  1441  1441 E AndroidRuntime: 	... 8 more

From the docs of the relevant package "net.gotev:uploadservice" it seems to expect that the configuration for the UploadService is set from the Application "onCreate" method (see https://github.com/gotev/android-upload-service/wiki/Getting-Started-with-4.x) but instead it's being called late (in the "initManager" method of the "FileTransferPlugin" class) and I suspect this being the cause. Since the plugin already sets it's own application class (com.orm.SugarApp), wouldn't it be wise to instead create a custom application class that extends the "com.orm.SugarApp" class and adds the relevant functionality to the onCreate method there (thus preventing the crash you see above)...

Need help for using this plugin with cordova code push

Platform: iOS

After downloading and installing the latest package using code push, we restart the app. But when we restart the app, it crashes because of

File FileUploadManager.m:

- (void)start
{
    NSURLSessionConfiguration *     configuration;
    
    NSParameterAssert(self.session == nil);                 // This line
...

So I was thinking if there is any way we can stop the session through the plugin before restarting the app, because I see a stop method in the same file.

Video upload corrupted

Hi,

Can someone please explain why this is added to the start of the file and also at the end?

--Boundary-8BDE7C70-89B7-40AA-B889-3B17B2C8793F Content-Disposition: form-data; name="file"; filename="1585023559770.mp4" Content-Type: application/octet-stream

I don't see how any file could open correctly after having this text added to the file. Is this a side-effect of me forcing the plugin to use "PUT" instead of "POST"?

If so then that's fine as I've commented out those sections from the forked version of this plugin.

"Sample Usage" question

I am fairly new writing Cordova apps \ Javascript. I am working on an app that allows users to upload videos to a server, and this plugin seems like a great way of doing it. However, I can't seem to get it working.

Based on the "Sample Usage" section of the Readme:

declare var FileTransferManager: any;
var config = {};
var uploader = FileTransferManager.init(config, callback);

When I put this in my javascript, after the deviceready event, it hangs on the declare. I'm not sure what I am missing here?

iOS 13.1.3 upload error

Hi,
after upgrading iOS 13.1.3 the plugin stopped working. When I try to upload a file (video), it stops with an undefined error: ERROR: uploader caught an error: undefined
The last task logged is: "did sync upload tasks"
I'm using the plugin in an Ionic 3 project. The plugin works correctly in iOS 13.1

Regards,

Pier

Cdvfile as input

In order to be compatible with cordova other plugins we should handle cdvfiles as input.

Are cookies appended to the HTTP requests?

My cordova application targets iOS and Android and we're using this plugin to upload pictures to an ASPNET Rest API service. The Application authenticates to the API using a cookie, something like ".ASPXAUTH". On Android devices, we're seeing an issue where cookies are not being appended to the uploads so they're failing. (debugging the actual requests shows 0 cookies).

In the headers section of the config, should I be manually adding in a Cookie: .ASPXAUTH=12345blahblahblah header, or is the intention that this would happen automatically?

two issues

Hello.

  1. Referring to the docs:
var payload = {
    "id": "sj5f9"
    "filePath": "/storage/emulated/0/Download/Heli.divx",
    "fileKey": "file",
    "serverUrl": "http://requestb.in/14cizzj1",
    "headers": {
        "api_key": "asdasdwere123sad"
    },
    "parameters": {
        "signature": "mysign",
        "timestamp": 112321321
    }
};

uploader.startUpload(options);

It should be: uploader.startUpload(payload );

  1. Please add response utf-8 support. If response is in utf-8 it displays ? charchters.

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.