
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
cordova-plugin-background-upload
Advanced tools
Cordova plugin for uploading file in the background
This plugin provides a file upload functionality that can continue to run while in background. It also includes progress updates which is suitable for long-term transfer operations for large files. Currently only 1 concurrent upload is possible at any time.
Supported Platforms
Installation
To install the plugin:
cordova plugin add cordova-plugin-background-upload --save
To uninstall this plugin:
cordova plugin rm cordova-plugin-background-upload
Sample usage
The plugin needs to be initialised before any upload. Ideally this should be called on application start. The uploader will provide global events which can be used to check the progress of the uploads.
declare var FileTransferManager: any;
var uploader = FileTransferManager.init();
uploader.on('success', function(upload) {
console.log("upload: " + upload.id + " has been completed successfully");
console.log(upload.statusCode,upload.serverResponse);
});
uploader.on('progress', function(upload) {
console.log("uploading: " + upload.id + " progress: " + upload.progress + "%");
});
uploader.on('error', function(uploadException) {
if (uploadException.id) {
console.log("upload: " + uploadException.id + " has failed");
} else {
console.error("uploader caught an error: " + uploadException.error);
}
});
Adding an upload is done via the startUpload
method. In case the plugin was not able to enqueue the upload, an exception will be thrown in the error event listener.
var payload = {
"id": "sj5f9"
"filePath": "/storage/emulated/0/Download/Heli.divx",
"fileKey": "file",
"serverUrl": "http://requestb.in/14cizzj1",
"showNotification": true,
"notificationTitle" : "Uploading images",
"headers": {
"api_key": "asdasdwere123sad"
},
"parameters": {
"signature": "mysign",
"timestamp": 112321321
}
};
uploader.startUpload(payload);
Configuration
To remove/abort an upload:
uploader.removeUpload(uploadId, function(){
//upload aborted
}, function(err){
//could abort the upload
});
The plugin runs on ios 9.0 and above. The code was based on the following blog: https://krumelur.me/2015/11/25/ios-background-transfer-what-about-uploads/.
Internally it uses NSUrlSession to perform the upload in a background session. When an uploaded is initiated, it will continue until it has been completed successfully or if the user kills the application. If the application is terminated by the OS, the uploads will still continue. When the user relaunches the application, after calling the init method, the success and error events will be emitted with the ids of these uploads. If the user chose to kill the application by swiping it up from the multitasking pane, the uploads will not be continued. Upload tasks in background sessions are automatically retried by the URL loading system after network errors as decided by the OS.
The minimum api level require is 21 and the background file upload is handled by the android-upload-service library. If the application is killed while uploading, either by the user or the OS, all uploads will be stopped. When the app is relaunched, the ids of these uploads will be emitted to the error listener. If an upload is added when there is no network connection, it will be retried as soon as the network becomes reachable unless the app is already killed.
On android Oreo, there are more strict limits on background services and it's recommended to use a foreground service with an ongoing notification to get more time for service execution: https://developer.android.com/about/versions/oreo/background Hence to prevent the service from be killed, an progress notification is needed on Android 8+.
If you have a web version also, you can use our javascript library designed to abstract the uploads. More info here:
Cordova-plugin-background-upload is licensed under the Apache v2 License.
Cordova-plugin-background-upload is brought to you by Spoon Consulting.
FAQs
Cordova plugin for uploading file in the background
We found that cordova-plugin-background-upload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.