xowiki::UploadPhotoForm method store_file (public)

 <instance of xowiki::UploadPhotoForm[i]> store_file

Defined in packages/xowiki/tcl/xowiki-uploader-procs.tcl

Ignore everything, which does not have an image/* mime type.

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
Source code:
if {![string match image/* ${:content_type}]} {
  ns_log notice "ignore store_file operation for ${:file_name} mimetype ${:content_type}"
  return {status_code 200 message ok}
}
#
# Mime type is ok, save the file under the filename either as a
# new item or as a new revision.
#
set package_id [${:parent_object} package_id]
set parent_id [${:parent_object} item_id]

set photo_object [::$package_id get_page_from_name -name en:${:file_name} -parent_id $parent_id]
if {$photo_object ne ""} {
  #
  # The photo page instance exists already, create a new revision.
  #
  ns_log notice "Photo ${:file_name} exists already"
  $photo_object set title ${:file_name}
  set f [::xowiki::formfield::file new -object $photo_object -name "image" -destroy_on_cleanup]
  $f set value ${:file_name}
  $f content-type ${:content_type}
  $f set tmpfile ${:tmpfile}
  $f convert_to_internal
  $photo_object save
} else {
  #
  # Create a new page instance of photo.form.
  #
  ns_log notice "new Photo ${:file_name}"
  set photoFormObj [::$package_id instantiate_forms  -parent_id $parent_id -forms en:photo.form]
  set photo_object [$photoFormObj create_form_page_instance  -name en:${:file_name}  -nls_language en_US  -creation_user [::xo::cc user_id]  -parent_id $parent_id  -package_id $package_id  -instance_attributes [list image [list name ${:file_name}]]]
  $photo_object title ${:file_name}
  $photo_object publish_status "ready"
  $photo_object save_new ;# to obtain item_id needed by the form-field
  set f [::xowiki::formfield::file new -object $photo_object -name "image" -destroy_on_cleanup]
  $f set value ${:file_name}
  $f content-type ${:content_type}
  $f set tmpfile ${:tmpfile}
  $f convert_to_internal
}

return {status_code 201 message created}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: