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

    Download Plug-In

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 205 Views 3 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.
    • F Offline
      felipe.sabino
      last edited by felipe.sabino

      Hi all!

      First, sorry about my english.

      So, i have a site with some zipped components (.tar.gz) and i want to make a plug-in for download this components.

      Actually my plug-in make the component download, but it's instable.
      I using the follow code:

      <span class="syntaxdefault">def&nbsp;download_product_http</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">param_1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">param_2</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">param_3</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">param_4</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">dialog</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">param_5</span><span class="syntaxkeyword">)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">Net</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">HTTP</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">RESTRICTED_HTTP_SERVER</span><span class="syntaxkeyword">)&nbsp;{&nbsp;|</span><span class="syntaxdefault">http</span><span class="syntaxkeyword">|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;SET&nbsp;HTTP&nbsp;SERVER&nbsp;FOR&nbsp;DOWNLOAD<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">response&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">http</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">request_head</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">URI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">escape</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">LINK</span><span class="syntaxkeyword">))&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;SET&nbsp;THE&nbsp;LINK&nbsp;AT&nbsp;THE&nbsp;HTTP&nbsp;SERVER<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">file_size&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">response</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'content-length'</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">to_i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;FOR&nbsp;PROGRESS&nbsp;BAR<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">open</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">product_tar_gz_name</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">"wb"</span><span class="syntaxkeyword">)&nbsp;{&nbsp;|</span><span class="syntaxdefault">file</span><span class="syntaxkeyword">|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">http</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">URI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">escape</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">temp_link</span><span class="syntaxkeyword">))&nbsp;do&nbsp;|</span><span class="syntaxdefault">str</span><span class="syntaxkeyword">|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">file</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">write&nbsp;str<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;CODE&nbsp;FOR&nbsp;INCREMENT&nbsp;PROGRESS&nbsp;BAR&nbsp;AT&nbsp;WEBDIALOG<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span class="syntaxdefault">end</span>
      

      This code works well for tar.gz files until 1 mb, when the size of the files exceeds 1 or 1.5 mb SKU crashes... i really dont know why...

      I've tried using the "model.definitions.load_from_url(url,handler)" but this works only for SKP files.
      I've looking for something more simple, someone with any idea?

      Thanks.

      Felipe

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        Have you tried the new rbz (zip format,) to put the components in a subdir of "Plugins", then move them to another folder after the extension installer unzips them ??

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • F Offline
          felipe.sabino
          last edited by

          @dan rathbun said:

          Have you tried the new rbz (zip format,) to put the components in a subdir of "Plugins", then move them to another folder after the extension installer unzips them ??

          I do not know if I understand What you said, but here we go.

          1 - I cant change the compress format of the components, there is to many components and is the default of my company.

          2 - I've tried to download the file in the subdir "...\Google SkethUp8\Plugins\Components" for then move them to the correct folder, but the SKU still crashes while download is in progress..

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            Have you tried using FTP protocol ??

            See the Net::FTP standard library.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              Instead of trying to deflate the compressed file as it arrives and finding it exceeds some size limit for this... why not download the compressed files into a temporary folder then use a 'command-line' cmd type file to extract their contents [most decompression apps have command-line options]... finally move the extracted files to their final destination, and tidy up by erasing the unneeded compressed files and their temporary folder...

              TIG

              1 Reply Last reply Reply Quote 0
              • F Offline
                felipe.sabino
                last edited by

                @dan rathbun said:

                Have you tried using FTP protocol ??

                See the Net::FTP standard library.

                I have ftp implemented too.
                I always try do download from http, if it fails then i try to download from ftp and it fails too. ( i cant use always ftp because in some client machines the ftp is blocked.)

                The weird is because during the download, SKU crashes in a feel machines, not in all... In my machine for example its always well succeed

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  Since he is using the extended Ruby libraries, with a full Ruby install...

                  @tig said:

                  Instead of trying to deflate the compressed file as it arrives ... why not download the compressed files into a temporary folder ...

                  Net::FTP

                  @tig said:

                  ... then extract their contents ...

                  Zlib

                  @tig said:

                  ... finally move the extracted files to their final destination, and tidy up by erasing the unneeded compressed files and their temporary folder...

                  FileUtils

                  I'm not here much anymore.

                  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