SketchUcation Plugin Store

 

 

Download Plug-In

Download Plug-In

Postby felipe.sabino » Thu Mar 08, 2012 11:19 pm

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:

Code: Select all
def download_product_http(param_1,param_2,param_3,param_4,dialog,param_5)

     
Net::HTTP.start(RESTRICTED_HTTP_SERVER) { |http|       # SET HTTP SERVER FOR DOWNLOAD
          
response http.request_head(URI.escape(LINK))    # SET THE LINK AT THE HTTP SERVER
          
file_size response['content-length'].to_i       # FOR PROGRESS BAR
          
open(product_tar_gz_name"wb") { |file|          
               
http.get(URI.escape(temp_link)) do |str|     
                    
file.write str
                    
# CODE FOR INCREMENT PROGRESS BAR AT WEBDIALOG
               
end     
          
}
     }
end


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
Last edited by thomthom on Fri Mar 09, 2012 9:49 am, edited 1 time in total.
Reason: Wrapped the code sample in a [code] block
felipe.sabino
 
Posts: 3
Joined: Tue Jul 12, 2011 7:56 pm
Name: Felipe

Re: Download Plug-In

Postby Dan Rathbun » Thu Mar 08, 2012 11:51 pm

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 ??
User avatar
Dan Rathbun
Top SketchUcator
 
Posts: 4069
Joined: Tue Oct 06, 2009 3:06 am
Location: Florida, USA
Name: Dan Rathbun
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: education
Level of SketchUp: Advanced

Re: Download Plug-In

Postby felipe.sabino » Fri Mar 09, 2012 12:09 am

Dan Rathbun wrote: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..
felipe.sabino
 
Posts: 3
Joined: Tue Jul 12, 2011 7:56 pm
Name: Felipe

Re: Download Plug-In

Postby Dan Rathbun » Fri Mar 09, 2012 1:38 am

Have you tried using FTP protocol ??

See the Net::FTP standard library.
User avatar
Dan Rathbun
Top SketchUcator
 
Posts: 4069
Joined: Tue Oct 06, 2009 3:06 am
Location: Florida, USA
Name: Dan Rathbun
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: education
Level of SketchUp: Advanced

Re: Download Plug-In

Postby TIG » Fri Mar 09, 2012 11:04 am

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
User avatar
TIG
Global Moderator
 
Posts: 13929
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Download Plug-In

Postby felipe.sabino » Fri Mar 09, 2012 1:35 pm

Dan Rathbun wrote: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
felipe.sabino
 
Posts: 3
Joined: Tue Jul 12, 2011 7:56 pm
Name: Felipe

Re: Download Plug-In

Postby Dan Rathbun » Fri Mar 09, 2012 2:16 pm

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

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

    Net::FTP

    TIG wrote: ... then extract their contents ...

    Zlib

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

    FileUtils
    User avatar
    Dan Rathbun
    Top SketchUcator
     
    Posts: 4069
    Joined: Tue Oct 06, 2009 3:06 am
    Location: Florida, USA
    Name: Dan Rathbun
    Operating system: Windows
    SketchUp version: 8
    License type: Pro
    SketchUp use: education
    Level of SketchUp: Advanced

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago

    Are you a Premium Member? Get your freebies here. Are you not a Premium Member yet? Upgrade your account to grab these freebies instantly.

    Ad Machine
    Robot
     
    Posts: 2012


    Return to Developers' Forum

    Who is online

    Users browsing this forum: fantoosh420 and 5 guests