- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowiki::File
::xowiki::File create ... \
[ -render_adp (default "0") ]
Defined in
Class Relations
::xo::db::CrClass create ::xowiki::File \ -superclass ::xowiki::PageMethods (to be applied on instances)
www-download (scripted, public)
<instance of xowiki::File> www-downloadThis web-callable method downloads the file content of the current File object. The following query parameter can be used to influence the behavior
- Testcases:
- xowiki_test_cases
# # The package where the object is coming from might be different # from the package on which it is delivered. Use the latter one # with the proper delivery information. # set package_id [::xo::cc package_id] # # Use always ad_returnfile_background, it is clever enough to use # the right delivery mode in case of doubt. # if {[:exists_query_parameter filename]} { set fn [::xo::backslash_escape \" [:query_parameter filename]] ns_set put [ns_conn outputheaders] Content-Disposition "attachment;filename=\"$fn\"" } set full_file_name [:full_file_name] if {![ad_file exists $full_file_name]} { # # This should not happen on a production system. In certain # testing setups, a system admin might not have provided the # full content repository. We fail more gracefully in this # case. # ad_log error "The file '$full_file_name' does not exist." "Maybe the content repository is (partially) missing?" return [::${:package_id} error_msg -status_code 500 [subst { No file for link <b>'[ns_quotehtml [ns_conn url]]'</b> available.<br> Please report this to the web master of this site. }]] } ::$package_id set mime_type ${:mime_type} ::$package_id set delivery ad_returnfile_background #:log "--F FILE=$full_file_name // ${:mime_type}" set geometry [::xo::cc query_parameter geometry ""] if {[string match "image/*" ${:mime_type}] && $geometry ne "" } { if {![regexp {^\d*x?\d*$} $geometry]} { error "invalid geometry $geometry" } set tmpdir [ad_tmpdir] if {![ad_file isdirectory $tmpdir/$geometry]} { file mkdir $tmpdir/$geometry } set scaled_image $tmpdir/$geometry/${:revision_id} if {![ad_file readable $scaled_image]} { set cmd [::util::which convert] if {$cmd ne ""} { if {![catch {exec $cmd -geometry $geometry -interlace None -sharpen 1x2 $full_file_name $scaled_image}]} { return $scaled_image } } } else { return $scaled_image } } set modtime [ad_file mtime $full_file_name] set cmptime [ns_set iget [ns_conn headers] If-Modified-Since] if {$cmptime ne ""} { if {[clock scan $cmptime] >= $modtime} { # # TODO: we should set the status_code and delivery the same # way, ... but keep things compatible for now. # ::xo::cc set status_code 304 ::$package_id set delivery ns_return return "" } } ns_set put [ns_conn outputheaders] Last-Modified [ns_httptime $modtime] return $full_file_nameVariables
::xowiki::File set __default_metaclass ::xotcl::Class ::xowiki::File set __default_superclass ::xotcl::Object ::xowiki::File set abstract_p f ::xowiki::File set auto_save false ::xowiki::File array set db_constraints {} ::xowiki::File array set db_slot \ {page_order ::xowiki::Page::slot::page_order creator ::xowiki::Page::slot::creator page_id \ ::xowiki::Page::slot::page_id creation_date ::xo::db::Object::slot::creation_date \ creation_user ::xo::db::Object::slot::creation_user object_id \ ::xo::db::Object::slot::object_id file_id ::xowiki::File::slot::file_id description \ ::xowiki::Page::slot::description text ::xowiki::Page::slot::text creation_ip \ ::xo::db::Object::slot::creation_ip object_title ::xo::db::Object::slot::object_title \ nls_language ::xo::db::CrItem::slot::nls_language package_id \ ::xo::db::Object::slot::package_id name ::xo::db::CrItem::slot::name mime_type \ ::xo::db::CrItem::slot::mime_type context_id ::xo::db::Object::slot::context_id \ security_inherit_p ::xo::db::Object::slot::security_inherit_p title \ ::xowiki::Page::slot::title revision_id ::xo::db::CrItem::slot::revision_id item_id \ ::xo::db::CrItem::slot::item_id last_modified ::xo::db::Object::slot::last_modified \ modifying_user ::xo::db::Object::slot::modifying_user publish_date \ ::xowiki::Page::slot::publish_date modifying_ip ::xo::db::Object::slot::modifying_ip} ::xowiki::File set folder_id -100 ::xowiki::File set form ::xowiki::FileForm ::xowiki::File set id_column file_id ::xowiki::File set mime_type text/plain ::xowiki::File set name_method {} ::xowiki::File set non_cached_instance_var_patterns {import_file do_substitutions} ::xowiki::File set object_type ::xowiki::File ::xowiki::File set object_type_key 00000000000011110001100100000011 ::xowiki::File set pretty_name {#xowiki.File_pretty_name#} ::xowiki::File set pretty_plural {#xowiki.File_pretty_plural#} ::xowiki::File set security_inherit_p t ::xowiki::File set sql_package_name ::xowiki::File ::xowiki::File set storage_type file ::xowiki::File set supertype content_revision ::xowiki::File set table_name xowiki_file ::xowiki::File set with_table true
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables