PhoneGap 3.5.0 FileTransfer onprogress issue unresolved

I can't seem to get the onprogress event handler to work when downloading a file. The success callback is triggered and the download goes through successfully, but for some reason, the progress events are not firing. Does anyone see any issues with my code below?

filesystem.root.getFile('/path/to/file', { create: true }, function (file) {

    var transfer = new FileTransfer();

    transfer.onprogress = function () {
        console.log(arguments);
    };

    transfer.download(
        'http://example.com/path/to/file',
        file.toURL(),
        function () { console.log('success'); },
        function () { console.log('error'); },
        true
    );

}, function () { console.log('error'); });

This app is built using PhoneGap version 3.5.0 and includes the latest file and file-transfer plugins. Testing is being conducted on an iPad running iOS 8.

Answer №1

It looks like you forgot to include the arguments variable in the onprogress function definition.

The correct format is:

transfer.onprogress = function (progressEvent) {
    console.log(progressEvent);
    console.log(progressEvent.loaded); //Loaded bytes
    console.log(progressEvent.total); //Total bytes
    console.log(progressEvent.lengthComputable); //TRUE if the destination server informs total file length
};

You can refer to the documentation here:

I hope this information proves helpful!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Show specific elements in a listview using JavaScript

I have created a dynamic listview using jQuery Mobile that currently shows 4 list items. The list is generated through JavaScript. $( document ).ready(function() { var data = [{ "name": "Light Control", "category": "category", "inf ...

Various web browsers may exhibit varying behaviors when processing extremely lengthy hyperlinks

I am curious to understand why browsers handle long URLs differently based on how they are accessed. Let me explain further: Within my application, there is a link to a specific view that may have a URL exceeding 2000 characters in length. I am aware that ...

Backand - How can I display the contents of variables using console.log() within Security Actions?

Is there a way to utilize console.log() in Backand, specifically within the server side functions like those found under Security & Auth > Security Actions? I have checked the Read.me which suggests using 'console.log(object) and console.error(obje ...

The array is present both before and after the res.json() call, however it appears empty in the response

When using Express to send a json response with res.json(), I am experiencing an issue where the value of records in the object sent via res.json() is empty. My code snippet looks like this: stats.activities(params).then(res => { processActivities ...

Errors occur when using jQuery Autocomplete alongside Angular HTTP

I have implemented an ajax autocomplete feature for my database using the jQuery-Autocomplete plugin. Below is my current code setup: HTML: <input ng-keyup="searchCustomer()" id="customerAutocomplete" type="text"> Angular $scope.searchCustome ...

Utilize a function on specific attribute values

I have a function in JavaScript that is designed to convert all relative URLs into absolute URLs. function rel2Abs(_relPath, _base); //_relPath represents the relative path //_base indicates the base URL Now, my objective is to implement this function on ...

Having trouble displaying HTML UL content conditionally in Reactjs?

My goal is to display a list of items, limited to a maximum of 5 items, with a "more" button that appears conditionally based on the number of items in the list. However, I am encountering an issue where passing in 5 li items causes them to be rendered as ...

In iOS 8, the MPMoviePlayerLoadStateDidChangeNotification can result in slow streaming for MPMoviePlayerController

I'm encountering a problem with iOS8 where it takes longer (around 4-8 seconds) to play a song in MPMovieSourceTypeStreaming compared to iOS7. Below is the code I'm using: self.moviePlayerController.movieSourceType = MPMovieSourceTypeStreaming; ...

Convert a portion of an object into a string to send in a server request

I have customized the fetch method of a Backbone Collection to make a request to a different URL under certain conditions, and I need to include some data with it. The modified fetch method (which I obtained from another solution on Stack Overflow) is as f ...

Node.js/Express/Jade scripts failing to load in the expected order

Imagine having this code snippet in a .jade file: doctype 5 html head title= title link(rel='stylesheet', href='/stylesheets/style.css') script(src='/javascripts/ocanvas-2.2.2.min.js', type='text/javascript') ...

When attempting to access Firestore on a non-local server without using a virtual machine on AWS, the following error occurs: { Error: Module 'grpc' not found

My code runs successfully locally and connects to the same firestore. However, when I push it to my release server and hit the endpoint, I encounter this error: { Error: Cannot find module 'grpc' at Function.Module._resolveFilename (module.j ...

The AJAX call was successful with a return code of 200, however an error

HTML code snippet: <a href="javascript:void(0)" onclick="$.join_group(<?=$USER_ID?>, <?=$groups[$i]["id"]?>)"><?=$language["join"]?></a> JavaScript function: $.join_group = function(user_id, group_id) { var input = "u ...

Incorporating Vue.js components into PHP applications

I am currently working on a project using PHP in conjunction with Vue.js and vue-router. In my PHP form handler, I have implemented functionality to send emails. What I am trying to achieve is redirecting the user to a specific component within my Vue ap ...

Controlling the display and status of DIV elements as radio button choices within a React application

I am seeking the React.js solution to a common challenge. I have five DIVs that will function as radio button options when clicked. This is what the HTML might look like: //List of option DIVs which act as radio buttons when clicked const options = () = ...

Display a message if the local storage is empty

Recently, I came across a javascript code snippet that is designed to save birthday data in local storage and then display the data within a div element. The current functionality only shows nothing if the storage is empty. However, I require it to display ...

Comparing Products: Enhance Your Selection with Jquery to Add or Remove Items

I am looking to incorporate a "product compare feature" into the product list on my website. I am curious about how I can create a Query String URL from the product list page using jQuery, like the example below. The generated compare URL should follow th ...

Developing a new NSObject using an NSArray

I'm currently working on a project where I need to create an NSObject class that includes an array containing the alphabet. However, when I try to set up the array, I encounter a warning that reads "Initializer element is not a compile-time constant." ...

Create a composition of several debounce promises in JavaScript

I am looking for a way to efficiently manage multiple costly server calls by continuously invoking a function that accepts a key and returns a promise containing an object. This object is guaranteed to have the requested key along with additional values, i ...

Delete Entries in MongoDB Collection According to Unique User Pairs

I have a collection of messages stored in MongoDB and I need to keep only the latest 500 records for each pair of users. Users are identified by their sentBy and sentTo attributes. /* 1 */ { "_id" : ObjectId("5f1c1b00c62e9b9aafbe1d6c&quo ...

Having trouble resetting Material UI Radio Button Group in Formik form within React?

formik.resetForm() is effective in resetting the value, but the Material UI radio button group does not reset correctly: The last selected radio button remains selected. How can I ensure the radio button group is reset properly after submission? import { u ...