Download Plug-In
-
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 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 /> </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">) { |</span><span class="syntaxdefault">http</span><span class="syntaxkeyword">| </span><span class="syntaxcomment"># SET HTTP SERVER FOR DOWNLOAD<br /> </span><span class="syntaxdefault">response </span><span class="syntaxkeyword">= </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">)) </span><span class="syntaxcomment"># SET THE LINK AT THE HTTP SERVER<br /> </span><span class="syntaxdefault">file_size </span><span class="syntaxkeyword">= </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 </span><span class="syntaxcomment"># FOR PROGRESS BAR<br /> </span><span class="syntaxdefault">open</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">product_tar_gz_name</span><span class="syntaxkeyword">, </span><span class="syntaxstring">"wb"</span><span class="syntaxkeyword">) { |</span><span class="syntaxdefault">file</span><span class="syntaxkeyword">| <br /> </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">)) do |</span><span class="syntaxdefault">str</span><span class="syntaxkeyword">| <br /> </span><span class="syntaxdefault">file</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">write str<br /> </span><span class="syntaxcomment"># CODE FOR INCREMENT PROGRESS BAR AT WEBDIALOG<br /> </span><span class="syntaxdefault">end <br /> </span><span class="syntaxkeyword">}<br /> }<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
-
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 ??
-
@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..
-
Have you tried using FTP protocol ??
See the Net::FTP standard library.
-
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...
-
@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
-
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 ...
@tig said:
... then extract their contents ...
@tig said:
... finally move the extracted files to their final destination, and tidy up by erasing the unneeded compressed files and their temporary folder...
Advertisement