Hi,
At the moment (OpenACS 5.3.0) the upload a file the CR TCL API offers the function: content::item::upload_file
But if you create a folder and a custom content_type is registered to the folder (content::folder::register_content_type), then isn't possible to use the function content::item::upload_file, to upload a file under the folder, because the function doesn't have a switch in order to pass the custom content_type. The solution is to use the "low level" function cr_import_content (in fact the function is used inside of content::item::upload_file) , that has the switch -other_type in order to manage custom content_types.
In order to access to the CR in a consistent way, It is possible to add a switch to content::item::upload_file to manage a custom content_type?
An example of the new code for content::item::upload_file could be:
ad_proc -public content::item::upload_file {
{-upload_file:required}
{-parent_id:required}
{-package_id ""}
{-other_type "content_revision"}
} {
Store the file uploaded under the parent_id if a file was uploaded
@author Malte Sussdorff (mailto:sussdorff@sussdorff.de)
@creation-date 2005-06-21
@param upload_file
@param parent_id
@param other_type
@return the revision_id of the generated item
@error
} {
set filename [template::util::file::get_property filename $upload_file]
if {$filename != "" } {
set tmp_filename [template::util::file::get_property tmp_filename $upload_file]
set mime_type [template::util::file::get_property mime_type $upload_file]
set tmp_size [file size $tmp_filename]
set extension [file extension $filename]
if {![exists_and_not_null title]} {
set title $filename
}
set existing_filenames [db_list get_parent_existing_filenames {}]
set filename [util_text_to_url \
-text ${title} -existing_urls "$existing_filenames" -replacement "_"]
set revision_id [cr_import_content \
-storage_type "file" -other_type $other_type -title $title -package_id $package_id $parent_id $tmp_filename $tmp_size $mime_type $filename]
content::item::set_live_revision -revision_id $revision_id
return $revision_id
}
}
Thanks for the help!
Jorge.