Home Download Buy Blog Forum Support

Plugin that will download a file and extract it

Plugin that will download a file and extract it

Postby jacksleight on Wed Nov 28, 2012 3:48 pm

Hi,

I'm trying to write a simple plugin that will download a file and extract it into a specific directory under the current project root. So for example, I'd have a command that takes two parameters:

Code: Select all
download http://example.com/myarchive.gz assets/components


And that would download http://example.com/myarchive.gz, extract it into [project root]/assets/components/myarchive, and then delete the old file.

I'm at a complete loss as to how to do this, and I'm struggling to find any similar examples to learn from. Any pointers in the right direction would be fantastic. Thanks in advance for any help.

Jack
jacksleight
 
Posts: 2
Joined: Wed Nov 28, 2012 3:42 pm

Re: Plugin that will download a file and extract it

Postby skuroda on Thu Nov 29, 2012 8:52 am

You should be able to write a command that first prompts for a URL, then for an extraction location. I'm sure there's some python library (or perhaps use a command like curl if you are only developing for nix systems) to get the file. I am also sure there is a python library to perform the extractions. Sorry I don't know exactly what they are, I am just making an assumption that they exist based on how widely python is used. In terms of prompting, you may be able to use something like window.show_input_panel (which is documented as part of the api).

Anyways, best of luck.
skuroda
 
Posts: 683
Joined: Fri Oct 05, 2012 8:11 am

Re: Plugin that will download a file and extract it

Postby highend on Thu Nov 29, 2012 9:39 am

For a starting point, take a look at: http://net.tutsplus.com/articles/news/i ... uts-fetch/
highend
 
Posts: 94
Joined: Fri Jan 20, 2012 2:47 pm

Re: Plugin that will download a file and extract it

Postby jacksleight on Thu Nov 29, 2012 10:57 am

Thanks guys! That Fetch plugin does almost exactly what I want already, so I may be able to build something on top of that. I'm not too hot on python, but will have a go.
jacksleight
 
Posts: 2
Joined: Wed Nov 28, 2012 3:42 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 2 guests