last day (16 days later) » 

11:53 AM
0
Q: Is it possible to get a download link from Windchill that I can use in other applications like an Electron app?

neolithI have built an Electron application which downloads files from Sharepoint. This works flawlessly. Soon the files will be transferred to Windchill and only be available there. When I substitute the download link with the link from Windchill, it doesn't work, although the link works inside the bro...

 
You could download files from the main process via the electron.net API but I would have a deeper look why some external site wants to do things electron blocks before that. Better save than sorry.
 
Well, unfortunately I can't download the files from the main process or at least I wouldn't know how. I have several HTML files that contain the links. Isn't there a way to force calling getURL anyhow?
 
You could take a look at the network tab in the devtools whether you find the download url of the file. If not, yes, fetching it via GET request won't work.
 
There is no download link unfortunately. Is there another way with a javascript function? This functionality is crucial for my app. I mean if Chrome can do it, why shouldn't Electron be able to?
@Rhayene Can you please explain me why this doesn't work and would work with the Electron.net API?
 
If you had a file url, you could download the file via rest request - with curl or in your app with the net api. This was a possible solution under the assumption that you could download the file directly from a rest resource. Since this assumption did not hold true, this is not the way you can go. It would have been only a workaround in the first place though.
 
11:53 AM
@Rhayene I think the download would work work without the Electron.net API, if I had a direct link to the file. Can you think of any other solution? I mean it must be possible, if it is possible in Chrome. Is it maybe possble to pass the link to Chrome and then get it back? I don't even understand why it doesn't work
 
Well, nobody here has a magic crystal ball. So your best chances of success is to reproduce this behaviour with as little code as possible and edit your question to include it. Then others have a chance to not only reproduce your problem, but may also see errors you don't see.
 
Well, it is impossible to give you access to my Windchill account. Since I don't understand what is not working, it is hard to come up with a link that excites the same behaviour :(
@Rhayene When I open the link directly in main.js via window.loadURL(windchill_link), it works. I don't understand what is going on here
 
Do it nevertheless - for yourself. You'll probably find the problem along the way or have code that works in the end. If it isn't the link, then look at the browser window options you used to create it or whether you have some content policy in play from your side. If you have reduced to a particular section of code - you may want to add it to your question.
With do it I meant that you should reduce the code as much as possible to isolate the error.
 
Yes, I understand. Sometimes reducing the code is hard for me, since I am such a noob, that I wouldn't even know which parts of the code are necessary.
The problem is I only have until the end of the week to get this to work. Else my application is going to the trash
Do you know how Electron fetches the links from the hrefs in the HTML file? Something must be wrong there
 
what do you do before navigating to windchill in the window?
 
12:09 PM
Well, my app is really simple. I load an index.html in the mainWindow. This index.html contains an iframe in which I load other HTML files, which then contain the download links to the cloud services. This works with SharePoint, but not with Windchill
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));

// Build menu from template
const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
// Insert menu
Menu.setApplicationMenu(mainMenu);
 
if you open that index.html in chrome - does it work?
 
From then on it is just Electrons normal download procedure. I just got rid off the save dialog
Yes, I just checked it. I can navigate to the HTML file which contains the Windchill link and it prompts me to choose where to save the file
 
ok then first step create a new electron app that only opens a window with standard settings and loads this index.html
nothing else around this - throw away code from your html that you think you don't need
 
12:25 PM
Created a new app
It does not make a difference. Nothing happens, when I click on the Windchill link, whereas it prompts me for login, when I click the SharePoint links
 
This is good, because you know now that nothing of the code you didn't transfer to the new app is at fault here. Now, do you have any metadata in your html?
 
Wait I stripped the HTML down to only the anchor tag
Then it prompts me for download, when I click
 
Now you know, that the problem is in your html - very good. Now you can add the parts you removed and watch out when it returns.
Adding the parts one after another starting with the ones you suspect the most
If a part is not responsible, you can remove it again for now.
 
12:45 PM
The problem is the iFrame
My index.html contains an iFrame in which I load the other HTML files, that contain the links
When I load the other HTML file directly, it works. If I load the index.html with the iFrame and then the rest inside there, it doesn't
 
Very good! Now you have a) a lot more information that you can add to your question to make answerable and b) you can think about whether you should load external sites inside an iframe or if a webview oder the electron alternative BrowserView would be better, because they run the content in its own process.
Also you could think whether you want to run it in an iframe at all.
 
Well, that is a whole different question then. I think there is a lot of information about iFrame alternatives and BrowserView etc.
Best solution for me would be to just exchange that line <iframe " id="1" src="tile_menu/top.html" ></iframe>
already tried <embed> instead, but it doesn't make a difference
I think a BrowserView would be the best solution, but then I have to restructure my whole app.
 
1:00 PM
I would still edit your question regarding the problem in the iframe - especially if the iframe works in chrome but not in electron. As your question is, it is too broad, and while you may have alternative solutions, you still don't know the reason for this behaviour (I also don't know right now).
Add your isolatet html code that causes it, if you want - you don't have to add the particular link. <link to windchill> works as well.
And while using alternative approaches may be one solution, it may not be the best one.
You may get better answers with your revised question.
 
1:17 PM
I edited the question accordingly. I hope that people still click it.
Thank you for your time! With your help I could trace down the origin of the bug
...myself
 
1:39 PM
You are welcome :) The approach we used is very helpful if you have no idea where to start searching. Kind of like throwing noodles at the fridge and look whether some of them stick xD Not very graceful but useful nevertheless. You yourself did already the first step by confirming whether the download works in a normal chrome window - excluding the external site from the list of suspects.
I don't remember who said this on twitter but I liked this sentence very much: "Debugging is like being a detective in a murder case, when you are the murderer at the same time, reconstruction how you did it."
*reconstructing
Btw your revised question looks a lot better now - good work. You did include the windchill link - I wanted to mention it in case this was not intended.
 

  last day (16 days later) »