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());
    }
  }