• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Downloading files from the Internet using Ruby

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 4 Posters 433 Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    Whaat
    last edited by 2 Sept 2009, 18:05

    I am wondering if it possible to download a file from the Internet using Ruby and then do something with the file automatically (again with Ruby).

    For example, when you open the 3D Warehouse from SketchUp, you have the ability to download a SKP file and it loads automatically into your current open SKP file. I would like to emulate this behaviour but for a different purpose.

    I don't want the user to determine the saved location for the download. The file would be downloaded to the user's temp folder and then loaded by the ruby script.

    Any ideas?
    Thanks.

    SketchUp Plugins for Professionals

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 2 Sept 2009, 18:47

      XMLHttpRequest
      http://en.wikipedia.org/wiki/XMLHttpRequest

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • W Offline
        Whaat
        last edited by 3 Sept 2009, 20:18

        @thomthom said:

        XMLHttpRequest
        http://en.wikipedia.org/wiki/XMLHttpRequest

        Could this be used download binary files? (zip files for example) It sounds like it can only be used for text or XML.

        SketchUp Plugins for Professionals

        1 Reply Last reply Reply Quote 0
        • T Offline
          tbd
          last edited by 3 Sept 2009, 20:37

          http://nagoon97.wordpress.com/2008/04/06/reading-binary-files-using-ajax/

          SketchUp Ruby Consultant | Podium 1.x developer
          http://plugins.ro

          1 Reply Last reply Reply Quote 0
          • W Offline
            Whaat
            last edited by 3 Sept 2009, 22:23

            OK, it looks possible to read binary files using javascript. But, I wonder if I can pass the binary string from a WebDialog back to Ruby using a callback function and then write the file to the user's temp directory? Does this sound possible?

            SketchUp Plugins for Professionals

            1 Reply Last reply Reply Quote 0
            • P Offline
              Phil Rader AIA
              last edited by 4 Sept 2009, 02:06

              I recall a video of Scott Lininger doing that with downloading data from an external server from sketchup and having that data create a 3d bar chart dynamically.

              Maybe Scott could clarify the method used.

              http://www.philrader.com

              1 Reply Last reply Reply Quote 0
              • T Offline
                tbd
                last edited by 4 Sept 2009, 08:14

                @whaat said:

                I wonder if I can pass the binary string from a WebDialog back to Ruby using a callback function and then write the file to the user's temp directory? Does this sound possible?

                why not ? just try it 😉
                have in mind that window.location might have a size limitation (depends on the browser) - so more than 2000 chars can bring trouble

                SketchUp Ruby Consultant | Podium 1.x developer
                http://plugins.ro

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 8 Sept 2009, 17:30

                  @unknownuser said:

                  @whaat said:

                  I wonder if I can pass the binary string from a WebDialog back to Ruby using a callback function and then write the file to the user's temp directory? Does this sound possible?

                  why not ? just try it 😉
                  have in mind that window.location might have a size limitation (depends on the browser) - so more than 2000 chars can bring trouble

                  I've not tried this, but Chris mentioned you can store data in hidden input fields and extract data from there. http://forums.sketchucation.com/viewtopic.php?f=180&t=21166#p177786

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  1 / 1
                  • First post
                    1/8
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement