Append Blender Files from a web server rather than local drive.

I have been searching for a script out there that can communicate with the internet- basically a script that can run in blender and allow me to append models and materials over a url on the internet (links for my dropbox account) rather than on my desktop - does anyone know of a plugin or script that can handle this sort of operation?

This is probably easier than it sounds. It is pretty simple to download data in Python using httplib2. It can be as easy as:


import httplib2

http = httplib2.Http()
resp, content = http.request('the url', method='GET')

Assuming you got a ‘200’ response, then ‘content’ has your file content. You can probably wrap that with BytesIO. That makes your in-memory ‘content’ have the same API as a typical file object so you should be able to pass that directly to the Blender LoadLibrary method to load in the data just like it was on a local disk.

I’m getting stopped before I start-- I keep trying to import httplib2 and run that script in blender python and it’s not working - is there an alternate module I need to install before it works?

yeah it says there is no module by that name in blender.

Yes, httplib2 is not part of Blender but you can add it just like a regular python module.

You can download it from here: https://pypi.python.org/pypi/httplib2/0.9

Then you want to extract the python3 version of the ‘httplib2’ directory along-side your .blend file. Blender automatically looks for extra python modules in the same directory as your .blend file.

You should have:

…/some-dir/your.blend
…/some-dir/httplib2

Ok is there another way to get a URL- I am seeing the plugin the plugin “renderfarm.fi” can upload a blend file to a web server without the additional module. - I am trying to find the best way to tackle a plugin that will interact with the web.

It is likely that the render farm module is using httplib2 or urllib for talking to the render farm servers. Your two options for doing this entirely in Python are to use an HTTP library or write your own from scratch.

You could do something like use the standard Python subprocess module to launch an external ‘wget’ or ‘curl’ command to contact an HTTP server and then process the stdout stream from that processes.

Yep Urllib works better because blender comes with the module. That was trickier than I thought it was going to be.
another problem is that blender doesn’t seem to allow opening files from the web, so any file that is I am appending from needs to be on the local disk somewhere.