[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Populate parts

On Thu, Jul 19, 2012 at 6:09 AM, Brian Wolf <..hidden..> wrote:
What is the best way to insert an associated photo in the file_part table?  Meaning, is there a way of duplicating the upload feature? 

We don't have a tool right now but one could be easily written.   It's not base-64 but you don't have to worry about escaping if you use our object model.

The easiest thing to do would be to create a small perl script that would import the files to the database, using what we have in scripts/file.pl as a starting point.  There are a few framework gotchas that will be eliminated in 1.4 in this area, but for now I think most of the code would be a little bit of boilerplate. 

The larger issue is likely to be interface design, to be honest.  

Pulling up the Python docs in case you want to do it in Python instead: http://packages.python.org/psycopg2/usage.html

Take a look at the section for Bytea:

mypic = open('picture.png', 'rb').read()
curs.execute("insert into blobs (file) values (%s)",

Our stored procedure is file__attach_part (you can look at this in pgAdmin).

If you'd like more help on this side, the development list might be better.

Best Wishes,
Chris Travers