Forum OpenACS Q&A: best method to upload files

Collapse
Posted by Hal Heisler on
I have recently been working through the development tuorial. I noticed that the content repository's TCL API has been improved and I was able to use the new content:: procs instead of the tcl lib that was included in the tutorial. I also used the content_type__create_attribute in my create.sql file to add an extra column to my mfp_notes table. My drop.sql script is kind of messy though because I first had to unset the live_revision and latest_revision columns in cr_items before I could call content_item__delete and acs_object__delete on my mfp_note objects.

Anyway, my question is this, what is the best way to upload files? Lets say for example that I want my mfp_note objects to have one attached file of unknown type.

I see that there is an attachments package, a file storage package, an image table and a folder called content-repository-content-files. I am not sure how best to proceed. Is there a package out there that I can look at that is already doing the right thing? Should I be using the content repository, storing files in the filesystem or in the database etc...

Once I get a better idea of which direction to go in I would like to add a download link in my note-list.tcl and the appropriate upload form widgets in note-edit.tcl.

Collapse
Posted by Malte Sussdorff on
Two options that make sense:

- Use the attachements package to handle the attachment of files to you objects. This is document throughout the toolkit, take a look at forums how this works.

- Alternatively you could store your files directly with the object itself. Contacts makes use of this behaviour at /contacts/www/files*. You could copy paste these files to your application and just replace party_id with mfp_note_id and that should do the trick.