示例#1
0
 private function addContentType(RequestInterface $request, StreamInterface $body)
 {
     if (!($uri = $body->getMetadata('uri'))) {
         return;
     }
     // Guess the content-type based on the stream's "uri" metadata value.
     // The file extension is used to determine the appropriate mime-type.
     if ($contentType = Mimetypes::getInstance()->fromFilename($uri)) {
         $request->setHeader('Content-Type', $contentType);
     }
 }