content::item::upload_file (public)

 content::item::upload_file -upload_file upload_file \
    -parent_id parent_id [ -package_id package_id ] [ -title title ]

Defined in packages/acs-content-repository/tcl/content-item-procs.tcl

Store the file uploaded under the parent_id if a file was uploaded

Switches:
-upload_file (required)
File to upload
-parent_id (required)
Parent ID
-package_id (optional)
-title (optional)
Title of the uploaded file
Returns:
revision_id of the generated item
Author:
Malte Sussdorff <sussdorff@sussdorff.de>
Created:
2005-06-21

Partial Call Graph (max 5 caller/called nodes):
%3 packages/bug-tracker/www/related-file-add.tcl packages/bug-tracker/ www/related-file-add.tcl content::item::upload_file content::item::upload_file packages/bug-tracker/www/related-file-add.tcl->content::item::upload_file ad_sanitize_filename ad_sanitize_filename (public) content::item::upload_file->ad_sanitize_filename content::item::set_live_revision content::item::set_live_revision (public) content::item::upload_file->content::item::set_live_revision cr_import_content cr_import_content (public) content::item::upload_file->cr_import_content db_list db_list (public) content::item::upload_file->db_list template::util::file::get_property template::util::file::get_property (public) content::item::upload_file->template::util::file::get_property

Testcases:
No testcase defined.
Source code:

    set filename [template::util::file::get_property filename $upload_file]
    if {$filename ne "" } {
        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 {$title eq ""} {

            # maltes: The following regsub garbles the title and consequently the filename as well.
            # "info_c+w.zip" will become "info_c+"
            # This is bad, first of all because a letter is missing entirely. Additionally
            # the title in itself should be the original filename, after all this is what
            # the user uploaded, not something stripped of its extension.
            # So I commented this out until someone can either fix the regsub but more importantly
            # can explain why the title should not contain the extension.

            # DRB: removing the explicit "." isn't sufficient because the "." in the
            # extension also matches any char unless it is escaped.  Like Malte, I
            # see no reason to get rid of the extension in the title anyway ...

            # regsub -all -- ".${extension}\$" $filename "" title
            set title $filename
        }

        set existing_filenames [db_list get_parent_existing_filenames {}]
        set filename [ad_sanitize_filename  -existing_names $existing_filenames  -collapse_spaces  -replace_with "_" $title]

        set revision_id [cr_import_content  -storage_type "file"  -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
    }
Generic XQL file:
<fullquery name="content::item::upload_file.get_parent_existing_filenames">
    <querytext>
    select name
      from cr_items
     where parent_id = :parent_id
  </querytext>
</fullquery>
packages/acs-content-repository/tcl/content-item-procs.xql

PostgreSQL XQL file:
packages/acs-content-repository/tcl/content-item-procs-postgresql.xql

Oracle XQL file:
packages/acs-content-repository/tcl/content-item-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: