Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

Is it possible to create a file download function?

nishihira
10-Marble

Is it possible to create a file download function?

I tried to create a function to download local storage information in a file but it did not work.
I have tried the following

 

    const fileName = "maintenance.csv";
    const fileContent = $scope.jsonToCsv(localStorage.getItem('records'));
    const blob = new Blob([fileContent], { type: "application/octet-stream" });
    const url = window.URL.createObjectURL(blob);
    const fileLink = document.querySelector('.file-link')
    fileLink.setAttribute("href", url);
    fileLink.setAttribute("download", fileName);
    fileLink.click()
    window.URL.revokeObjectURL(url);

 

This function is executed when the "file" widget with the class "file-link" is clicked.
However, while the file is downloaded in the preview, it does not work on iOS.
Please let me know if you know how to make the file downloadable.
Looking forward to hearing from you.

 

1 REPLY 1

View does not allow JS access to device for security reasons 

Announcements
Top Tags