cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading Pictures from file repository not possible

SOLVED
Highlighted

Re: Downloading Pictures from file repository not possible

for the question how to download a file?  -I  think from one side there are security restictions : ( stackoverflow.com :  "JavaScript Automatically Save Image File to Folder")

"There is no way for javascript to access the filesystem, this is due to security concerns. You can store the image data as a string in a lot of places though, such as browser storage. Luckily for you it looks as though you're trying to store it in a web server's folder!"

============

But there are other post's which sound more optimistic like : ( stackoverflow.com : How to save a base64 image to user's disk using JavaScript? ) Actually I tested this approach  and was able to download the files but unfortunately they are corrupt - are not completely downloaded so only part of the original file content was saved  – but content of this part  was ok!)

Therefore I tried to follow another approach using a file widget and trying to simulate a click event:

2019-10-25_19-11-13.jpg

 

The File Widget - File URL points to the repository location. Then  calling the folliwng script:

 

//called by buttion click
$scope.testButton= function() {
console.log("test button click");
//this works only if one file Widget exist
let e1=document.querySelector('a.twx-file.twxHyperlink')
fireClick(e1)
}
///==== definition of firClick function:

function fireClick(node){
    if (document.createEvent) {
        var evt = document.createEvent('MouseEvents');
        evt.initEvent('click', true, false);
        node.dispatchEvent(evt);
        console.log("MoseEvents")
    } else if (document.createEventObject) {
         console.log("onclick fireEvent")
        node.fireEvent('onclick') ; 
    } else if (typeof node.onclick == 'function') {
        console.log("onclick function")
        node.onclick(); 
    }
}
//----------------------------------------------------

 

this will start a downlaod of the specified File URL

I tested it in Preview and on IOS i-Pad 6 and this worked ok in current version. But on IOS it asks for credential

View solution in original post

Announcements
Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection