Beispiel #1
0
 /**
  * Creates a new servlet part instance with the data from the HTTP part.
  *
  * @param \AppserverIo\Psr\HttpMessage\PartInterface $httpPart The HTTP part we want to copy
  *
  * @return \AppserverIo\Appserver\ServletEngine\Http\Part The initialized servlet part
  */
 public static function fromHttpRequest(PartInterface $httpPart)
 {
     // create a temporary filename
     $httpPart->write($tmpFilename = tempnam(ini_get('upload_tmp_dir'), 'tmp_'));
     // initialize the servlet part instance
     $servletPart = new Part();
     $servletPart->setName($httpPart->getName());
     $servletPart->setFilename($httpPart->getFilename());
     $servletPart->setTmpFilename($tmpFilename);
     // return the servlet part instance
     return $servletPart;
 }
Beispiel #2
0
 /**
  * Adds a part to the parts collection.
  *
  * @param \AppserverIo\Appserver\ServletEngine\Http\Part $part A form part object
  * @param string                                         $name A manually defined name
  *
  * @return void
  */
 public function addPart(PartInterface $part, $name = null)
 {
     if ($name == null) {
         $name = $part->getName();
     }
     $this->parts[$name] = $part;
 }