Download files with a SketchUp plugin
-
@dan rathbun said:
Does not make sense.
If many users are not technical enough to run a one-click installer executable, how are they technical enough to install your package?
And.. didn't they succeed in downloading and installing Sketchup's one-click installer executable despite their lack of technical skill?
It does make sense. I was not talking about Window's one-click install but the hacking required to get it working on a Mac.
Also, having to require users to download a 25mb file and install it just to use my plugin is not acceptable in my eyes. I want this plugin to work on most systems by default, without any mucking around and dependencies.
@dan rathbun said:
And by the way.. pik (which is the Win32 equivalent of RVM,) uses the 7za.exe command line executable. (The file must be in the path environment var, or use an absolute path.)
There's also a DLL version. It's Free OpenSource, under GNU LPGL.
Command line versions are available for Win, Unix, Linux, OSX, etc.
http://www.7-zip.org/download.htmlSo this would be to extract a zip then? I got around local extraction because I do that server side and pull each file in manually, but would be interesting in case I change my mind or need that behavior in another plugin.
@unknownuser said:
I "upgraded" my Sketchup Ruby to 1.8.7 using this [url=http://stackoverflow.com/questions/3333163/how-to-update-ruby-in-google-sketchup:38tqxa52]trick[/url:38tqxa52]
Thanks for the link, if I need to upgrade I'll have to check that out.
@unknownuser said:
I think it is more easy to create an extensions (PC/Mac) which downloads the file from a given URL (with redirect and authentification) than packaging curl
Do you have an example of an extension that would download a file from the web? I asked around and searched quite a lot to no avail. Also, by extension, do you mean a C/C++ extension (I'm assuming so...)?
It seems like curl works fine for this use case (since it is working already and requires only a few lines of code and a very small .exe file). If there is a good reason to go with something else I'd love to hear it... Why do you think it is more easy to create an extension?
Thanks for all your replies guys!
-
pros for C/C++ ruby extension
• you can download directly to memory without the need to save to disk first
• no need to spawn to command line - faster
• provide a progress bar / cancel without the need to poll curl output
• smaller package sizecons
• must code it -
@unknownuser said:
pros for C/C++ ruby extension
• you can download directly to memory without the need to save to disk first
• no need to spawn to command line - faster
• provide a progress bar / cancel without the need to poll curl output
• smaller package sizecons
• must code itHow easy/hard is it to make it cross-*platform?
-
@thomthom said:
@unknownuser said:
pros for C/C++ ruby extension
• you can download directly to memory without the need to save to disk first
• no need to spawn to command line - faster
• provide a progress bar / cancel without the need to poll curl output
• smaller package sizecons
• must code itHow easy/hard is it to make it cross-*platform?
I'd also like to know this. Also would love to know if there is any open-source code or tutorials out there about how to make such an extension.
I am lacking in C knowledge and doing something like this would be a rather difficult task for me at this point.
Any info would be appreciated.
Cheers,
Dana -
As an update to this post, I am near complete with a Ruby C extension that downloads a file or files within a Ruby plugin that works on Mac and Windows. I will be releasing it as an open-source project and will post again when it is available. It is strait-forward to use and uses the powerful cURL (libcurl) library. Till then...
-
-
@ishboo said:
As an update to this post, I am near complete with a Ruby C extension that downloads a file or files within a Ruby plugin that works on Mac and Windows. I will be releasing it as an open-source project and will post again when it is available. It is strait-forward to use and uses the powerful cURL (libcurl) library. Till then...
Very good. Thanks in advance.
Fredo
-
-
-
Agreed, that's cool!
Chris
-
Thanks Dana. Just curious, since there are so many plugins posted here and people need to be registered and logged-in to download them, will your plugin handle the login?
-
@jim said:
Thanks Dana. Just curious, since there are so many plugins posted here and people need to be registered and logged-in to download them, will your plugin handle the login?
?
We're talking about generic downloader here I think. Not a plugin downloader... -
@thomthom said:
We're talking about generic downloader here I think. Not a plugin downloader...
What's the difference? Maybe my question should have been: Could the downloader be used to download plugins for SCF where a user is required to be logged in to have access to the file?
-
As a generic down-loader it will work through something like a webdialog, where the url-side contains files that can be downloaded; but once you get into a public-type web-site like SCF then the whole browser coding possibilities are setup to protect the user, and it will always asks for a 'save' confirmation via an unavoidable dialog to prevent virus invasions etc. In a database-type system what is picked 'on-screen' is merely a link to a db and the file is elsewhere - the thing that's then downloaded in 'protected', you'll probably never get the direct link to the very file itself, which lies under layers of protection to prevent backtrack hacking through html folder-paths and thereby potentially allowing the getting of all such files en mass...
As part of a 'tool' that allowed you to download plugins 'direct' from SCF you'd need to have paths available to the tool from a db ? How is the arrival folder to be determined ? Like 3dWarehouse lets you download/use SKP files from clicking links, but then you still need to select a save path etc... -
TIG,
You are perfectly right. Downloading by program (specially binary files) is something where we could go to an uncontrolled path.
What could be useful however is a Ruby method to download text file (like a public HTML page), usually to a temporary directory, just the time to read it.
The point is that you can do it from a Web dialog (via XMLHttpRequest), but sometimes you may want to check 'silently' whether something has changed on the web.
Otherwise better invoke the traditional "download dialog box" of the browser.
I have this function in LibFredo6 check for Update, but I did not enable it for several reasons:- it may not work depending on your local security configuration
- on Mac, it does not put the focus on the small download window, except the very first time
But the main reason is that I think it is always preferable that the user goes to the plugin web page and then have an opportunity to read the text and instructions, rather than to download 'blindly' files.
As an illustration, I have enabled the download file function for the plugin RemoveLonelyVertices (you should see now a small blue arrow). I am intersted in knowing what users get when clicking on it.
Fredo
-
What I was talking about in this post specifically is a generic file downloading utility written in C that has Ruby bindings so a plugin developer could use the code in their application if they needed to download something from the web. This would be for developers only and would be added into their application and would be supplied a URL and a path to save the file.
If you want, you could modify the plugin to handle some sort of authentication, but out of the box it just supports basic downloading (not following redirects or anything). I may add this in as the need arises (or you can fork the code and add it once I release the code). It taps into the cURL library, so anything cURL (libcurl) does should be possible to add into the tool...
I'll release the code as soon as possible so people can play around with it. I am just working through some hurdles in cross-platform and SketchUp specific issues. It works fine from the command line right now.
I am building this as part of a larger project of a plugin downloading tool, which will also be released shortly. I am planning on releasing a screencast here to demo its functionality in the next week or two. I will keep you all updated on this!
Thanks for all the interest!
-
As an update to my previous post, I have the initial code on Github here:
https://github.com/danawoodman/google-sketchup-file-downloader
... please read the README file to understand what the plugin does. Not everything in the README is functional/correct but is more of a wishlist so to speak.The code currently only works from the command line like so:
cd example/ ruby test_plugin.rb
... which will download files from the web onto the local system using both of the available methods
download_file()
anddownload_files()
.Trying to load the plugin from SketchUp fails with something like:
Error: #<LoadError: /path/to/file-downloader/example/file_downloader.bundle: Failed to load /path/to/file-downloader/example/file_downloader.bundle>
This is where I am stuck and need some assistance. I'm not seeing why the plugin can't be loaded into Ruby. Generating the bundle was done by running the "src/extconf.rb" file with Ruby 1.8.6-p420 and then make.
Note that I haven't done much work on Windows as I am not yet familiar with how to build the extension to work on Windows. If anyone out there has experience in this area, please feel free to fork the code and make changes or send me a message with what needs to be done to accomplish this.
This is my first C extension so I am sure I am doing things wrong, if you have some suggestions, please let me know! Really hoping someone with more C extension experience than me can help contribute!
Cheers,
Dana -
Have you looked at TBD's C-Extension project?
https://github.com/TBD/OpenSUP/tree/master/SUExt -
@thomthom said:
Have you looked at TBD's C-Extension project?
https://github.com/TBD/OpenSUP/tree/master/SUExtYes, I have. It was written for use on Windows and even after modification all I can get is a "Failed to load" error, just like the issue I'm coming across with the file downloader tool.
I've tried to set up a really bare-minimum C extensions to load into SU (for the Mac) but have thus far failed. If anyone can offer a pointer as to why a "Failed to load" error would be thrown, I would be much appreciative!
Cheers,
Dana -
removed the x64 version and now it crashes with EXC_BAD_ACCESS in Init_file_downloader. will keep you updated on debug progress.
Advertisement