FileSystem browseForDirectory + Server.downloadFile
-
I'm trying to make a button that asks the user where they would like to download a file to, and then trigger the download. Do I need two different steps / functions for this? This is where I'm at - I can't figure where I'd put the browsforDirectory function inside here.... (or how to reference it without having a previous step to the whole process):
const downloadsFolder = FileSystem.getFolder(FileSystem.Downloads); inline function startDownloadOSX() { Server.setBaseURL("https://myserver etc"); local f = downloadsFolder.getChildFile("INSTALLER.pkg"); download = Server.downloadFile(urlOSX, {}, f, downloadCallback); }
-
Here's something to get you started. Notice you only need one download function for all operating systems. Don't repeat yourself ;)
HiseSnippet 1070.3ocsVssaaaCFlxIpXxaqXEXO.D9hBY.OW6sttgEDLWeZvXI1FQoMcWkwHQYSDIRCRZ2YD32s8H02fseRIYqjZj0ZfoKr0+Q98ejZpTDRUJgD43c45ETjyW4Frlqm2aNgwQi5ibdp64DklJwYr5tdAQonQHGmi9MCCGuiQ1mO7qcIIDdHcGKD5sBVH8LVJSui6zN+NKIYHIhdIKsj1urynPAumHQrDvyQtsPKHg2RlQGSLpUwE47jAQLsPFnIZpBzoqHZcvbw64Y5+VlhcSB0PzFE.NJiMp2bVRzzhXUgPNGOcWjeTVj+stmyhXa4uKC7MVA3cVTNG3T4wfT6OCH4TBRGmAom4FDJYKz6jXvyW5NhCEjXBjpKCkLcQU9vQt8DfFbcyTxszgRfXqE9upUqFX3m5mTsJjtUZbD.1DAIRMTjDAE5SwCYIzf0PUOs4LpNiseIl8Krv3DIc1VWbhkZoLA3y3ILNEGujGpYBNVv6tTqE71FvIEI9ghzEBN.yF3Ujjkz5UuqpGKF6mS4AjV5A7YfmLPYRfec7omhqMI3c0.M77fyBmQe8at3rZm.7nIJZIQWMZb+IWEjKFDnzDotHD7gPvaS0MfjhjFbN8JflesbPWqdSkguE58HII2.8l9OLlpum39AGW067p5kGQJnO4OnpwhqXbHE5WKflPC03rLdsF3BF54TbDUoYbh0mwEJTbJ9RpBPrpbZqDKKOuRUvajh2qnCEx9LIb.B4Z+GzFTx2QLoMWach00LUeZLDAQVY3m+bL7eSf6VuU2ZQtIdAT4JpzjA6RTTnR3WatVuP8Ku3EoqUVgXpNrVcaABdVQj3Xn5YbqodXlVLv2u1nwAW95yNavEMWb6LiAV88vY+WDDfo4mYAGq0PKQC7cafXqw1d1hhY8Srdv5mMY+uw59MUsuroTm7XglNg6a6XqtoJ9ghhi2qr7tjDXZZehMqCkOlg97ko2XJM6lWLJB6Kt+Rnm7osDJLqgujhB9HNSOYAMm11JDk89GuxBkOw.u8lQ8IZhYKVNOPuETolYfiSe5J3ZfrcZdt8opa0hEVcyGy.HqsReZ9FurwJDKxXP9LF5u1dWweOqy5sDc9yNJxJ5H9TnimpMqBYpyEofeIRPMmJnOd0JrTWDsLgnu+ldyUZ4BfL+8VuZVgxUL85xW48Yr9u0it9+SEhOycJSGNe+XrxdvHTS9+.i4WZ90tChigQ9c.7X2gu6Pug7+33uPrD1.N6bhVxfdA2wKSCfuUHjBmNmCq8AdPw1Xpktkg1jABn7HKw+.O4BaancxE1tPHJkDJEWGlMuYtV9Krb.LwseEhG74P.MtMxNCB141pYKTJ7EBWGFZB+uCFU1uMe+AXyOb.17xCvle7.r4UGfM+zAXyO+n1X93rWuTKRyFG.FSGXWF43LfSfNKaWH5ek4bPTJ
-
@d-healey Thanks Dave :) I'd prefer to make an app like you have which unpacks the samples to the desired location, but I feel that writing the Link file in AppData directory is going to lead to a bunch of permissions issues on OSX.
-
@DanH There are no permission issues writing to appdata because that's a user controller folder.
-
@d-healey sure but this would be a separate app.... I'd rather not have the user open the plugin in their DAW and then have to wait for the samples to download before being able to use their DAW for anything else. I thought about making the app the same name as the plugin so it uses the same AppData folder but I'm unsure if this will cause some other issues
-
@DanH I think you might run into issues with two apps with the same name. You could do what I did, I use one app for both purposes but the download stuff is only active when it's running as a standalone.
-
@d-healey so you supply the plugin and the standalone? and use the standalone for the server stuff?
-
@DanH Correct. You can use
Engine.isPlugin()
to determine if your app is running as a plugin or as standalone and disable/enable stuff accordingly. -
@d-healey ok, but then I guess my idea of making a separate app by the same name might actually work then. Will give it some thought, thanks
-
@d-healey so your app downloads and unpacks several zips, and updates the link file, all with one button?
-
@DanH Yes essentially, but mine uses expansions so there can be multiple link files.
-
@d-healey yes I'm just looking through the code in your repo.
-
If you want to integrate my system into your app send me a message and we can discuss licensing.
-
@d-healey GPL ;)
-
@DanH Even better, take all you want.
-
@d-healey :)
Just going back to the snippet you shared with me earlier, in the download function f needs to be defined as a file but this file will be different for each OS so.... how can I define it as such? Another if statement?
inline function startDownload() { Engine.showYesNoWindow("Select Folder", "Select the destination folder", function(response) { if (response) { FileSystem.browseForDirectory(downloadsFolder, function(dir) { if (isDefined(dir) && dir.isDirectory()) { Server.setBaseURL("https://myserver etc"); var f = dir.getChildFile("MAC-INSTALLER.pkg"); // HERE download = Server.downloadFile(url, {}, f, downloadCallback); } }); } });
-
@DanH Look at the part where I set the URL based on the OS. You can do the same thing for the file name.
-
@d-healey Yes, think I've got it working :crossed_fingers: