File attachments or blobs

2 views
Skip to first unread message

device55

unread,
Jul 23, 2009, 7:30:05 PM7/23/09
to SimPCoRe
Do you have plans to support file attachments in SimPCoRe? Or did I
miss it in the documentation?

Murphy

unread,
Jul 23, 2009, 8:50:34 PM7/23/09
to simp...@googlegroups.com
great question ... i was going to write a "file handler/helper" - but
i talked with sammy, and he got all pissy about it ... meaning: people
have very STRONG feelings about how files should be handled, and i
guess i wanted to get feedback from the world before i took on such an
immense task ... good news is, sammy has a FileHelper class he can
post to the files section, and hopefully that will help ...

my guess is, files could be handled quite easily ... just this:

1) recognize a property's value is a file
2) copy and store it in a central location (md5 hash name in a "blobs"
directory)
3) make the "handle" easily accessible when getting the property's
value - like a getBinary() method

what do you think ???

Sam

unread,
Jul 23, 2009, 11:17:55 PM7/23/09
to SimPCoRe
I posted the FileManager class to the files area, nothing too fancy;
one catch to getting it to work though...in the PCR database, the "v"
field needs to be changed to have the type "longtext", since blobs
take up so much space.

With the filemanager it takes files on your server and puts them into
the PCR.
Example:
//store file
$fm = new FileManager();
$fm->storeFile('pcr:root/files', 'mynewfile', '/path/to/file.ext');


//render file
$fm = new FileManager();
$fm->renderFile('pcr:root/files/mynewfile');

device55

unread,
Jul 24, 2009, 5:28:30 PM7/24/09
to SimPCoRe
So Sam, does this imply that the file is stored in the database as a
property and not the filesystem?

Sam

unread,
Jul 24, 2009, 11:08:15 PM7/24/09
to SimPCoRe
Yes, the file is stored in the database and is represented as a node
with properties containing the file information.
> > $fm->renderFile('pcr:root/files/mynewfile');- Hide quoted text -
>
> - Show quoted text -

Murphy

unread,
Aug 3, 2009, 6:24:28 PM8/3/09
to SimPCoRe
perfect example of different approaches ... i like sammy's helper
class - actually, it's quite cool ... that being said, i am more of a
file system kind of guy - meaning, i would probably store the file
somewhere on the FS - probably rename it to the md5 file hash name -
and then just point to it in a prop somewhere, while storing the
particulars (mime type, etc.) ... but both ways work - it's just how
you want to do it ...


murph
Reply all
Reply to author
Forward
0 new messages