original_string: public function put(MediaInterface $media, Request $request) {
      $content_type = $request->headers->get('Content-Type', "");
  
      if (empty($content_type)) {
        throw new BadRequestHttpException("Missing Content-Type header");
      }
  
      // Since we update both the Media and its File, do this in a transaction.
      $transaction = $this->database->startTransaction();
  
      try {
  
        $this->service->updateSourceField(
          $media,
          $request->getContent(TRUE),
          $content_type
        );
  
        return new Response("", 204);
      }
      catch (HttpException $e) {
        $transaction->rollBack();
        throw $e;
      }
      catch (\Exception $e) {
        $transaction->rollBack();
        throw new HttpException(500, $e->getMessage());
      }
    }
code: public function put(MediaInterface $media, Request $request) {
      $content_type = $request->headers->get('Content-Type', "");
  
      if (empty($content_type)) {
        throw new BadRequestHttpException("Missing Content-Type header");
      }
  
      // Since we update both the Media and its File, do this in a transaction.
      $transaction = $this->database->startTransaction();
  
      try {
  
        $this->service->updateSourceField(
          $media,
          $request->getContent(TRUE),
          $content_type
        );
  
        return new Response("", 204);
      }
      catch (HttpException $e) {
        $transaction->rollBack();
        throw $e;
      }
      catch (\Exception $e) {
        $transaction->rollBack();
        throw new HttpException(500, $e->getMessage());
      }
    }
code_tokens: public function put ( MediaInterface $ media , Request $ request ) { $ content_type = $ request -> headers -> get ( 'Content-Type' , "" ) ; if ( empty ( $ content_type ) ) { throw new BadRequestHttpException ( "Missing Content-Type header" ) ; } // Since we update both the Media and its File, do this in a transaction. $ transaction = $ this -> database -> startTransaction ( ) ; try { $ this -> service -> updateSourceField ( $ media , $ request -> getContent ( TRUE ) , $ content_type ) ; return new Response ( "" , 204 ) ; } catch ( HttpException $ e ) { $ transaction -> rollBack ( ) ; throw $ e ; } catch ( \ Exception $ e ) { $ transaction -> rollBack ( ) ; throw new HttpException ( 500 , $ e -> getMessage ( ) ) ; } }
docstring: Updates a source file for a Media.
  
  @param \Drupal\media\MediaInterface $media
  The media whose source file you want to update.
  @param \Symfony\Component\HttpFoundation\Request $request
  The request object.
  
  @return \Symfony\Component\HttpFoundation\Response
  204 on success.
  
  @throws \Symfony\Component\HttpKernel\Exception\HttpException
docstring_tokens: Updates a source file for a Media .