Electron.AutoUpdater.OnDownloadProgress not getting called during differential update download - electron

We are using SignalR package to show the download progress to our electron desktop application. But it was found that the Electron.AutoUpdater.OnDownloadProgress was not getting called during differential update download after Electron.AutoUpdater.DownloadUpdateAsync(); was called.
enter image description here
However after deleting all the files inside C:\Users\username\AppData\Local\electron-updater and calling DownloadUpdateAsync(); the OnDownloadProgress works.
enter image description here
enter image description here
Electron Package: ElectronNET.API Version:13.5.1
.Net Version: 5.0
Node Version: v14.15.0
enter image description here
Electron.AutoUpdater.OnDownloadProgress += async (info) =>
{
var percentage = Math.Round(Convert.ToDouble(info.Percent), 1);
var totalsizeinmb = FormatSize(Convert.ToInt64(info.Total), "MB");
var downloadspeedinmb = FormatSize(Convert.ToInt64(info.BytesPerSecond), "MB");
var transfereedinmb = FormatSize(Convert.ToInt64(info.Transferred), "MB");
Console.WriteLine("percentage: " + percentage + "totalSize: " + totalsizeinmb + "downloadspeed: " + downloadspeedinmb + "transferSpeed: " + transfereedinmb);
await app.ApplicationServices.GetRequiredService().Clients.All.SendAsync("ReceiveDownloadProgress", percentage.ToString(), downloadspeedinmb, transfereedinmb, totalsizeinmb);
};

Related

Unable to view screenshots in Jenkins reports

My jenkins reports do not show the screenshots captured in the runs. (They are run on a MAC). However, when I run the same job locally (windows machine), the reports have the screenshots.
I see the error as below in the Jenkins report.
When I try to open the image, It shows below. It's unable to find the path to the image actually.
Error : http://*****-mac:8080/job/***Test/job/******/ws/target/screenshots/2019-01-14/Sign%20In20190114154253.png
Actual: http://*****-mac:8080/job/***Test/job/******/HTML_20Report/target/screenshots/2019-01-14/Sign%20In20190114154253.png
I'm using the below code to capture the screenshot. It does capture the screenshots & I can see them in the actual location.
I don't know when I did a mistake, these images are not seen as links/not available in the report:
public void captureScreenshot() throws IOException {
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String dateForScreenshots = dateFormat.format(date);
File localScreenshots = new File(new File("target/screenshots"), dateForScreenshots);
if (!localScreenshots.exists() || !localScreenshots.isDirectory()) {
localScreenshots.mkdirs();
}
System.setProperty("org.uncommons.reportng.escape-output", "false");// this is to create a link in ReportNG
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String destination = System.getProperty("user.dir") + "/target/screenshots/" + dateForScreenshots + "/" + getDriver().getTitle() + Utils.generateRandomString() + ".png";
File screenshotName = new File(destination);
//Now add screenshot to results by copying the file
FileUtils.copyFile(scrFile, screenshotName);
Reporter.log("<br> <img src='" + destination + "' height='90' width='160' /><br>");
Reporter.log("");
}
From this line
Error : http://*****-mac:8080/job/***Test/job/******/ws/target/screenshots/2019-01-14/Sign%20In20190114154253.png
I think that Jenkins cannot find the target branch in the workspace folder (ws). Probably you need to specify the workspace folder in the Jenkins job (as in this answer) or just change the destination variable somehow to something like (added /HTML_20Report):
String destination = System.getProperty("user.dir") + "/HTML_20Report/target/screenshots/" + dateForScreenshots + "/" + getDriver().getTitle() + Utils.generateRandomString() + ".png";

uploading files using filetransfer plugin on cordova ios

Im using jquery with cordova to build an app , on android everything works like a charm , but on ios the uploading is not working using filetransfer plugin .
this is the function i use to upload the picture that the user select already using the file plugin :
function uploadFile() {
var fileURI = $("#selectedPicture").attr("src");
var options = new FileUploadOptions();
options.fileKey = "file";
options.mimeType = "image/jpeg";
options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
var params = new Object();
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(fileURI, serviceURL+"uploadFile",function(r){
alert(r.response);
}, fail,
options);
}
var fail = function (error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
on the console i don't get any error or message .
i added those to lines on my infoplist file :
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
PS 1 : i use ios 9.2
PS 2 : i use cordova 6 .
PS 3 : the normal ajax works great only the upload thats not working .
PS 4 : i test the code using the latest ios simulator .
the problem was from the image size i tried to upload .
i just selected an other image and i got what i was looking for .

how to run a cordova/phonegap plugin asynchrounously - fileTransfer plugin

I have used cordova filetransfer plugin. I am uploading a file using fileTransfer plugin's upload function.
The problem is that upload works synchronously and application UI freezes while the file is being uploaded by this plugin.
I want the file upload to run asynchronously and user should be able to interact on UI while upload is in progress.
My cordova application is targeted for iOS and Windows.
I have used cordova filetransfer plugin. I am uploading a file using fileTransfer plugin's upload function.
The problem is that upload works synchronously and application UI freezes while the file is being uploaded by this plugin.
I want the file upload to run asynchronously and user should be able to interact on UI while upload is in progress.
My cordova application is targeted for iOS and Windows.
My javascript function which calls the cordova file-transfer plugin is as below:
var uploadVideo = function(path) {
//UPLOAD VIDEO TO SERVER
var fileURL = path;
var win = function(r) {
console.log("Code = " + r.responseCode);
};
var fail = function(error) {
console.log("An error has occurred: Code = " + error.code);
};
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
options.mimeType = "text/plain";
var params = {};
params.value1 = "test";
params.value2 = "param";
options.params = params;
var ft = new FileTransfer();
ft.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
var perc = Math.round(progressEvent.loaded / progressEvent.total * 100);
$('progress').val(perc);
}
};
ft.upload(fileURL, encodeURI("http://<serverpath>/<endpoint>"), win, fail, options);
};
As soon as this script/function is invoked, user is unable to interect with html page. Page kind of freezes and user can't input any text in text boxes or any other UI interaction.

Phonegap / Cordova File Transfer Upload Image as Base64 String not working in ios

I'm working on uploading image as base64 image stream from phonegap/cordova application, it works perfectly fine in Android but not working in ios, however in ios it works when the image is as png/jpg but when it is as base64 image stream its not working, Please can anybody help me out with the same.
Here is my code for the same,
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = "test.jpg";
options.mimeType = "image/jpeg";
options.chunkedMode = false;
options.params = {
"key": "test.jpg",
"AWSAccessKeyId": awsKey,
"acl": acl,
"policy": policyBase64,
"signature": signature,
"Content-Type": ""
};
var ft = new FileTransfer();
ft.upload(imageURI, s3URI + "",
win, fail, options);
}
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
alert(r.response);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
}
Version 1.5.0 of the file transfer plugin has already added that functionality. The patch was applied 14 Dec 2015.
You can see the commit here.
Upgrading the plugin solved the problem in my case at least.
Set chunkMode true when use base64 for upload using phonegap
I set chunkMode true but still file is not transferring on server .It seems that cordova file transfer plugin does not support base64 image for upload on iOS.

Titanium Studio to Grails imge post

I am trying to POST an image to my grails application and I'm not having much luck.
My titanium code is:
function upload(){
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function(e){
Ti.API.info(picMedia + " : " +message.value);
Ti.API.info('IN ERROR ' + e.error);
alert('Sorry, we could not upload your photo! Please try again.');
};
xhr.onload = function(){
Ti.API.info('IN ONLOAD ' + this.status + ' readyState ' + this.readyState);
};
xhr.onsendstream = function(e){
Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress);
};
// open the client
xhr.open('POST', 'http://localhost:8080/FYP/Profile/appUploader');
// send the data
xhr.send({
media: picMedia,
message: message.value,
});
}
My grails code is as follows:
def appUploader(){
println "MEDAI PARAMS: " + params.media
def f = request.getFile('media') ;
println "HERE: " + f
if (request.getFile(params.media).getOriginalFilename()) {
println "FROM APP: " + request.getFile('myFile').getOriginalFilename()
return
}
}
Im getting error from the mobile app and error on the "if" line in the web app.
What am i doing wrong?
we had the same problem in one of our apps. The difficulty is that titanium is not really able to handle binary files in that case.
We did the following:
create base64 encoded string of the image on client side
post this string to the backend
decode base64 to image again
We analyzed a lot of network traffic and in most cases titanium tries to send the file but due to javascript its alway converted into some kind of ascii and this is not usable by the server side.

Resources