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

FTP zip file upload

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 2 Posters 835 Views 2 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.
  • J Offline
    joshcastellano
    last edited by 3 Jun 2012, 05:01

    Hi guys,
    Have searched the forum for answers all day and I have gotten no where. I hope anyone of you could shed some light on this. I thought I had found the answer yesterday but I was wrong. I know that it's been touched on once before and I apologize for bringing it up again if you all wanted the subject dead.

    I assumed I would be able to use the net/ftp class in Ruby to upload a ZIP file to a web server. I read that I could but this afternoon I realized that Sketchup might not have the net/ftp class built in. I know I can install a full Ruby framework but I would rather not do that as I'm hoping to duplicate this on other machines "out of the box." I tried including the net/ftp library from a full install to my local machine along with the 'socket.so ' + 'monitor.rb' files and that doesn't seem to work.

    Is this even possible? The ZIP file just contains images of the SKP model. I ZIP'ed them so that I wouldn't have to open and close an FTP connection many times.

    I read in the forum that someone was looking for a similar solution a couple of years ago. "How much are you willing to pay," was one of the answers. Though I do think there is an answer out there, I'm just looking for a direction. I even researched the 'win32API.' Thought I might be able to do use that. Should I attempt at using the WebDialog and use Javascript to upload the file?

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 3 Jun 2012, 11:08

      Reeding:
      [The ftp:// protocol](http://msdn.microsoft.com/en-us/library/aa767732(v) .

      and:
      [(HTML 4.01) <input type=file> element](http://msdn.microsoft.com/en-us/library/ms535263(v)

      .. so I'd say a WebDialog would be the quickest way.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • D Offline
        Dan Rathbun
        last edited by 3 Jun 2012, 11:35

        This might be of some use: Minimal-Upload

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • J Offline
          joshcastellano
          last edited by 3 Jun 2012, 15:44

          Thanks for the prompt reply, Dan. I also agree that a WebDialog would be the way to go at this time. I'm fluent in Javascript and PHP but was hoping this could be done using one programming language client side.

          I'll be happy to report once I get that file transferred over and will share the snippet with the community. Shouldn't be too difficult using Javascript and that example you provided.

          On a side note, is it possible to pack a full Ruby install along with a plugin for Sketchup? I figure that if I'm going to distribute this, users are going to have to extract the plugin into the Plugins folder. Automating that along with a full Ruby install would take the same amount of effort, right? Possibly less if it is automated (kind of like that web exporter EXE file which was really an extracted archive).

          Thanks, again, Dan. I'll post my solution for other before/after me with the same challenge.

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 3 Jun 2012, 21:00

            @joshcastellano said:

            I also agree that a WebDialog would be the way to go at this time. I'm fluent in Javascript and PHP but was hoping this could be done using one programming language client side.

            Not possible. You will need server-side PHP ".asp" scripts.

            Do a Google search on "+javascript +file +upload"
            You'll find tons of examples out there. CodeProject and StackOverflow, etc.

            Likely, your WebDialog will open a webpage at YOUR website, using dlg.set_url()

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 3 Jun 2012, 22:09

              @joshcastellano said:

              On a side note, is it possible to pack a full Ruby install along with a plugin for Sketchup?

              Not necessary, and a bad idea. The installer executable (for Windows,) has already been created. (And it's 24.4 Mb !!)

              1) List that a full Ruby install is a dependency for such a plugin.

              And include this link:

              Ruby v1.8.6-p287 Windows One-Click Installer
              2) List that a $LOAD_PATH appending script, in the SketchUp "Plugins" directory, is needed to point SketchUp's Ruby to the full Ruby library directories.

              Just point users to this link:

              Ruby LOAD PATHs script (Win32)

              @joshcastellano said:

              I figure that if I'm going to distribute this, users are going to have to extract the plugin into the Plugins folder. Automating that along with a full Ruby install would take the same amount of effort, right? Possibly less if it is automated (kind of like that web exporter EXE file which was really an extracted archive).

              a) Well you can check Platform.

              See my post: FAQ: Detect if plugin is running on the Mac vs PC ?

              b) You can check the $LOAD_PATH Array,.. and even use Kernel.test(?d,"C:/Ruby186"), etc., to determine if they do or do not have a full ruby install.

              You can also check the environment thru Ruby's ENV hash, to see if the normal Ruby environment vars have been set. (ie: RUBYOPT, etc.) .. or:
              if ENV['PATH'] =~ /(C:\\Ruby186\\bin)/i

              ... and if not, ...

              c) To download it, call in Ruby:

              UI.openURL("http://rubyforge.org/frs/download.php/47082/ruby186-27_rc2.exe")

              It depends on the user's default browser.. that will be used to d/l it, and where it ends up.
              On my system I use Google Chrome, so it ends up in:
              ENV['USERPROFILE'] + "\My Documents\Downloads"
              This can be a problem, because the name of docs dir varies depending on Windows version, ("Documents" vs "My Documents",) and is localized for the user's language.

              So you'll likely need to ask the user to browse to the installer and run it manually.. or use the UI.openpanel() to have the user point to it, then execute it using %x[*command*]

              ie: (on my system)
              usrdir = File.expand_path(ENV['USERPROFILE']) exepath = File.join(usrdir,"My Documents/Downloads/ruby186-27_rc2.exe") %x[exepath]

              But you'd need to have the user point to it, thus:

              usrdir = File.expand_path(ENV['USERPROFILE'])
              installer = UI.openpanel("Please Select Ruby Installer...",usrdir,"ruby186-27_rc2.exe")
              if installer && File.exist?(installer)
                exepath = File.expand_path(installer)
                %x[exepath]
              end
              

              And Ruby on OSX is whole other complicated story.

              😢

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • J Offline
                joshcastellano
                last edited by 4 Jun 2012, 00:15

                @dan rathbun said:

                Not possible. You will need server-side PHP ".asp" scripts.

                Oh, yes, I agree that that is impossible. I meant that I hoped for one single program as a solution. In this case Ruby. And that the likely solution is going to be several program languages with server-side processing to process the uploaded file.

                1 Reply Last reply Reply Quote 0
                • J Offline
                  joshcastellano
                  last edited by 4 Jun 2012, 00:24

                  Wow! This is thorough! I can't thank you enough for your insights. You've given me several paths to take as a solution to this. If I can convince users of the plugin to use a full Ruby library and install it, that will limit the number of hoops needed to pass through.

                  Having a prerequisite library doesn't sound all that bad now that it can be easily suggested to potential users of a plugin.

                  Thanks a Million, Dan. I'll keep the community updated on what I go with.

                  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