Ejemplo n.º 1
0
 /**
  * Function serves the attachment by provided guid and exits.
  * @todo: Permission handling
  * @todo: Direct filesystem serving
  * @todo: Configuration options
  */
 public function get_serve(array $args)
 {
     $att = new midgard_attachment($args['guid']);
     if (midgardmvc_core::get_instance()->configuration->enable_attachment_cache) {
         midgardmvc_core::get_instance()->dispatcher->header('Location: ' . midgardmvc_core_helpers_attachment::get_url($att));
         midgardmvc_core::get_instance()->dispatcher->end_request();
     }
     $blob = new midgard_blob($att);
     midgardmvc_core::get_instance()->dispatcher->header('Content-type: ' . $att->mimetype);
     /**
      * If X-Sendfile support is enabled just sending correct headers
      */
     if (midgardmvc_core::get_instance()->configuration->enable_xsendfile) {
         midgardmvc_core::get_instance()->dispatcher->header('X-Sendfile: ' . $blob->get_path());
     } else {
         echo $blob->read_content();
     }
     midgardmvc_core::get_instance()->dispatcher->end_request();
 }
Ejemplo n.º 2
0
 private function on_deleting(midgard_attachment $attachment, $params)
 {
     midgardmvc_core_helpers_attachment::remove_from_cache($attachment);
 }