cr_write_content-file (private)

 cr_write_content-file [ -string ] [ -item_id item_id ] \
    [ -revision_id revision_id ] [ -mime_type mime_type ] \
    [ -content content ] [ -content_length content_length ] \
    [ -storage_area_key storage_area_key ] [ -filename filename ]

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

Switches:
-string
(boolean) (optional)
-item_id
(optional)
-revision_id
(optional)
-mime_type
(optional)
-content
(optional)
-content_length
(optional)
-storage_area_key
(optional)
-filename
(optional)

Partial Call Graph (max 5 caller/called nodes):
%3 ad_returnfile_background ad_returnfile_background (public) cr_fs_path cr_fs_path (private) security::csp::add_static_resource_header security::csp::add_static_resource_header (public) security::secure_conn_p security::secure_conn_p (public) cr_write_content-file cr_write_content-file cr_write_content-file->ad_returnfile_background cr_write_content-file->cr_fs_path cr_write_content-file->security::csp::add_static_resource_header cr_write_content-file->security::secure_conn_p

Testcases:
No testcase defined.
Source code:
    if {![info exists filename]} {
        set path [cr_fs_path $storage_area_key]
        set filename $path$content
    }
    if {$filename eq ""} {
        error "No content for the revision $revision_id. This seems to be an error which occurred during the upload of the file"

    } elseif {![file readable $filename]} {
        ns_log Error "Could not read file $filename. Maybe the content repository is (partially) missing?"
        ns_return 404 text/plain {}

    } elseif$string_p } {
        set fd [open $filename "r"]
        fconfigure $fd  -translation binary  -encoding [encoding system]
        set text [read $fd]
        close $fd
        return $text

    } else {
        # JCD: for webdavfs there needs to be a content-length 0 header
        # but ns_returnfile does not send one.   Also, we need to
        # ns_return size 0 files since if fastpath is enabled ns_returnfile
        # simply closes the connection rather than send anything (including
        # any headers).  This bug is fixed in AOLServer 4.0.6 and later
        # but work around it for now.
        set size [file size $filename]
        if {$size == 0} {
            ns_set iupdate [ns_conn outputheaders] "Content-Length" 0
            ns_return 200 text/plain {}
        } else {
            ::security::csp::add_static_resource_header -mime_type $mime_type
            if {[namespace which ad_returnfile_background] eq "" || [security::secure_conn_p]} {
                ns_returnfile 200 $mime_type $filename
            } else {
                ad_returnfile_background 200 $mime_type $filename
            }
        }
    }
XQL Not present:
Generic
PostgreSQL XQL file:
<fullquery name="cr_write_content-file.write_file_content">
    <querytext>
          select :path || content
          from cr_revisions
          where revision_id = :revision_id
      </querytext>
</fullquery>
packages/acs-content-repository/tcl/revision-procs-postgresql.xql

Oracle XQL file:
<fullquery name="cr_write_content-file.write_file_content">
    <querytext>
          select :path || filename
          from cr_revisions
          where revision_id = :revision_id
      </querytext>
</fullquery>
packages/acs-content-repository/tcl/revision-procs-oracle.xql

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