Need to download customized data log files from flexy

I have developed datalog in customized csv file. File has name with timestamp.
I generate 15 file everyday with timestamp.now customer wants to download yesterday file from webpage. Please tell me how to do it.Because file name is different everyday because of timestamp.

You could have your customer connect to the device over eCatcher and run something like Filezilla to grab the file over an FTP connection. Or you could write a script in the BASIC section to email him that file that you generated. If you want to be able to do it from a webpage though, I think you’d need to create a page in ViewON with some way to enter the timestamp data and grab it that way.

I have already script to send files via mail to Client. I told them to download file using FileZilla.
but they want webpage or ViewON screen from where they will download file by clicking the button. They need it to save files on PC.

You should be able to create a button in ViewON and run something like this Javascript code below:

function downloadFile()
{
type=“text/plain”;
// Create an invisible A element
const a = document.createElement(“a”);
a.style.display = “none”;
document.body.appendChild(a);
// Set the HREF to a Blob representation of the data to be downloaded
a.href = “…/fileToSend.csv”;

// Use download attribute to set set desired file name
a.setAttribute(“download”, “fileToSend.csv”);
// Trigger the download by simulating click
a.click();
// Cleanup
window.URL.revokeObjectURL(a.href);
document.body.removeChild(a);
}

In this example, the file that will be downloaded will need to match the name of the CSV file that you’ve created. You’ll need to replace the “FileToSend.csv” with the correct name

My url & file name gets change everyday.So i used your script & add ewon tag in it. “Filename” & “address” are my ewon tag which contains file name & url.But doesn’t work.Please tell me how to add ewon string tag to url & to file name.I don’t have javascript programming knowledge.
function downloadFile()
{
type= “button”;
// Create an invisible A element
const a = document.createElement(“a”);
a.style.display = “none”;
document.body.appendChild(a);
// Set the HREF to a Blob representation of the data to be downloaded
a.href = getEwonTagVal(‘address’);
// Use download attribute to set set desired file name
a.setAttribute(“Download”, getEwonTagVal(‘Filename’));
// Trigger the download by simulating click
a.click();
// Cleanup
window.URL.revokeObjectURL(a.href);
document.body.removeChild(a);
}

You could do something like this to pull values of tags

Below I just created a text object and gave it the animation text on string for a string tag that’s on the Flexy. Note the unit id on the left side.

After that you could call that unit id and read the value from it in java like the example below and just call the variable you made

var url = document.getElementById(“UID_1600783711870”).value;

tried following but still not working.“UID_1600854083501” contains url as http://192.168.0.29/usr/Aditya_13092020.csv & “UID_1600854277614” contains Aditya_13092020.csv string.I don’t understand what I am doing wrong.

function downloadFile()
{
var url = document.getElementById(“UID_1600854083501”).value;
var fname = document.getElementById(“UID_1600854277614”).value;
type= “button”;
// Create an invisible A element
const a = document.createElement(“a”);
a.style.display = “none”;
document.body.appendChild(a);
// Set the HREF to a Blob representation of the data to be downloaded
a.href = “url”;
// Use download attribute to set set desired file name
a.setAttribute(“download”, “fname”);
// Trigger the download by simulating click
a.click();
// Cleanup
window.URL.revokeObjectURL(a.href);
document.body.removeChild(a);
}

Hi @Aditya,

Did you purchase the license for ViewON for additional support? If that’s the case then I could try and take a look at this over teamviewer and help you debug it. If not I could recommend you try this way instead.

var url = "http://192.168.50.123/rcgi.bin/ParamForm?AST_Param=$dtUF$uf/usr/Myfile.txt
window.open( url , “download”);

You’d need to call the variables for the ip address and for the name of the vile in your var url though.

Thank You . It works.