sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    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

      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
      • thomthomT Offline
        thomthom
        last edited by

        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

          @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
          • tbdT Offline
            tbd
            last edited by

            Link Preview Image
            Reading binary files using Ajax

            A growing number of web applications are making more and more use of client-side technologies because thanks to Ajax, it is now possible to write more fluid and more responsive web applications using only client-side technologies. Now, web developers from all around the globe are releasing really interesting utilities and applications using only client-side technologies, many…

            favicon

            nagoon97's Weblog (nagoon97.wordpress.com)

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

            1 Reply Last reply Reply Quote 0
            • W Offline
              Whaat
              last edited by

              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

                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
                • tbdT Offline
                  tbd
                  last edited by

                  @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
                  • thomthomT Offline
                    thomthom
                    last edited by

                    @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
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement