Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
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.
View does not allow JS access to device for security reasons