diff --git a/core/lib/Drupal/Core/Asset/AssetDumper.php b/core/lib/Drupal/Core/Asset/AssetDumper.php
index a5228992e11c1bd5794ceff1f519a2741bdf78f0..60b725a40d17e2e2adcd3c0e951faec6447ea9fc 100644
--- a/core/lib/Drupal/Core/Asset/AssetDumper.php
+++ b/core/lib/Drupal/Core/Asset/AssetDumper.php
@@ -62,7 +62,7 @@ public function dump($data, $file_extension) {
     // generating a file that won't be used.
     if (extension_loaded('zlib') && \Drupal::config('system.performance')->get($file_extension . '.gzip')) {
       try {
-        if (!file_exists($uri . '.gz') && !$this->getFileSystem()->saveData(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
+        if (!file_exists($uri . '.gz') && !$this->getFileSystem()->saveData(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FileSystemInterface::EXISTS_REPLACE)) {
           return FALSE;
         }
       }
diff --git a/core/lib/Drupal/Core/File/FileSystem.php b/core/lib/Drupal/Core/File/FileSystem.php
index 994267972cb9a8566614c593adf003ef8a4cfacb..0c5e9a19db7c59fb9e4aa0d43dd02d45c3220cab 100644
--- a/core/lib/Drupal/Core/File/FileSystem.php
+++ b/core/lib/Drupal/Core/File/FileSystem.php
@@ -446,10 +446,10 @@ public function move($source, $destination, $replace = self::EXISTS_RENAME) {
    *   default scheme (file://) will be used.
    * @param int $replace
    *   Replace behavior when the destination file already exists:
-   *   - FILE_EXISTS_REPLACE - Replace the existing file.
-   *   - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename
-   *     is unique.
-   *   - FILE_EXISTS_ERROR - Do nothing and return FALSE.
+   *   - FileSystemInterface::EXISTS_REPLACE - Replace the existing file.
+   *   - FileSystemInterface::EXISTS_RENAME - Append _{incrementing number}
+   *     until the filename is unique.
+   *   - FileSystemInterface::EXISTS_ERROR - Do nothing and return FALSE.
    *
    * @see \Drupal\Core\File\FileSystemInterface::copy()
    * @see \Drupal\Core\File\FileSystemInterface::move()
diff --git a/core/lib/Drupal/Core/File/FileSystemInterface.php b/core/lib/Drupal/Core/File/FileSystemInterface.php
index 48e833847c64222306978972ade1b0ac5a8400de..4d8b6674aa4ae264b57f90f0babe1b58dda037e4 100644
--- a/core/lib/Drupal/Core/File/FileSystemInterface.php
+++ b/core/lib/Drupal/Core/File/FileSystemInterface.php
@@ -281,8 +281,10 @@ public function validScheme($scheme);
    * - If file already exists in $destination either the call will error out,
    *   replace the file or rename the file based on the $replace parameter.
    * - If the $source and $destination are equal, the behavior depends on the
-   *   $replace parameter. FILE_EXISTS_REPLACE will error out.
-   *   FILE_EXISTS_RENAME will rename the file until the $destination is unique.
+   *   $replace parameter. FileSystemInterface::EXISTS_REPLACE will replace the
+   *   existing file. FileSystemInterface::EXISTS_ERROR will error out.
+   *   FileSystemInterface::EXISTS_RENAME will rename the file until the
+   *   $destination is unique.
    * - Provides a fallback using realpaths if the move fails using stream
    *   wrappers. This can occur because PHP's copy() function does not properly
    *   support streams if open_basedir is enabled. See
@@ -295,10 +297,10 @@ public function validScheme($scheme);
    *   URI may be a bare filepath (without a scheme).
    * @param int $replace
    *   Replace behavior when the destination file already exists:
-   *   - FileManagerInterface::FILE_EXISTS_REPLACE - Replace the existing file.
-   *   - FileManagerInterface::FILE_EXISTS_RENAME - Append _{incrementing
-   *     number} until the filename is unique.
-   *   - FileManagerInterface::FILE_EXISTS_ERROR - Throw an exception.
+   *   - FileSystemInterface::EXISTS_REPLACE - Replace the existing file.
+   *   - FileSystemInterface::EXISTS_RENAME - Append _{incrementing number}
+   *     until the filename is unique.
+   *   - FileSystemInterface::EXISTS_ERROR - Throw an exception.
    *
    * @return string
    *   The path to the new file.
@@ -367,10 +369,10 @@ public function deleteRecursive($path, callable $callback = NULL);
    *   default scheme (public://) will be used.
    * @param int $replace
    *   Replace behavior when the destination file already exists:
-   *   - FILE_EXISTS_REPLACE - Replace the existing file.
-   *   - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename
-   *      is unique.
-   *   - FILE_EXISTS_ERROR - Do nothing and return FALSE.
+   *   - FileSystemInterface::EXISTS_REPLACE - Replace the existing file.
+   *   - FileSystemInterface::EXISTS_RENAME - Append _{incrementing number}
+   *     until the filename is unique.
+   *   - FileSystemInterface::EXISTS_ERROR - Do nothing and return FALSE.
    *
    * @return string
    *   The path to the new file.
@@ -396,10 +398,10 @@ public function move($source, $destination, $replace = self::EXISTS_RENAME);
    *   wrapper URI.
    * @param int $replace
    *   Replace behavior when the destination file already exists:
-   *   - FILE_EXISTS_REPLACE - Replace the existing file.
-   *   - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename
-   *     is unique.
-   *   - FILE_EXISTS_ERROR - Do nothing and return FALSE.
+   *   - FileSystemInterface::EXISTS_REPLACE - Replace the existing file.
+   *   - FileSystemInterface::EXISTS_RENAME - Append _{incrementing number}
+   *     until the filename is unique.
+   *   - FileSystemInterface::EXISTS_ERROR - Do nothing and return FALSE.
    *
    * @return string
    *   A string with the path of the resulting file, or FALSE on error.
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 9153fac739d470fe77f420f5313a1fc565f836b2..30ec79cff85955c0603ba5dd6981693d139d7b25 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -129,8 +129,9 @@ function file_load($fid, $reset = FALSE) {
  * - If file already exists in $destination either the call will error out,
  *   replace the file or rename the file based on the $replace parameter.
  * - If the $source and $destination are equal, the behavior depends on the
- *   $replace parameter. FILE_EXISTS_REPLACE will error out. FILE_EXISTS_RENAME
- *   will rename the file until the $destination is unique.
+ *   $replace parameter. FileSystemInterface::EXISTS_REPLACE will error out.
+ *   FileSystemInterface::EXISTS_RENAME will rename the file until the
+ *   $destination is unique.
  * - Adds the new file to the files database. If the source file is a
  *   temporary file, the resulting file will also be a temporary file. See
  *   file_save_upload() for details on temporary files.
@@ -143,12 +144,13 @@ function file_load($fid, $reset = FALSE) {
  * @param int $replace
  *   (optional) Replace behavior when the destination file already exists.
  *   Possible values include:
- *   - FILE_EXISTS_REPLACE: Replace the existing file. If a managed file with
- *     the destination name exists, then its database entry will be updated. If
- *     no database entry is found, then a new one will be created.
- *   - FILE_EXISTS_RENAME: (default) Append _{incrementing number} until the
- *     filename is unique.
- *   - FILE_EXISTS_ERROR: Do nothing and return FALSE.
+ *   - FileSystemInterface::EXISTS_REPLACE: Replace the existing file. If a
+ *     managed file with the destination name exists, then its database entry
+ *     will be updated. If no database entry is found, then a new one will be
+ *     created.
+ *   - FileSystemInterface::EXISTS_RENAME: (default) Append
+ *     _{incrementing number} until the filename is unique.
+ *   - FileSystemInterface::EXISTS_ERROR: Do nothing and return FALSE.
  *
  * @return \Drupal\file\FileInterface|false
  *   File entity if the copy is successful, or FALSE in the event of an error.
@@ -156,7 +158,7 @@ function file_load($fid, $reset = FALSE) {
  * @see file_unmanaged_copy()
  * @see hook_file_copy()
  */
-function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
+function file_copy(FileInterface $source, $destination = NULL, $replace = FileSystemInterface::EXISTS_RENAME) {
   /** @var \Drupal\Core\File\FileSystemInterface $file_system */
   $file_system = \Drupal::service('file_system');
   /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
@@ -181,7 +183,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
     // If we are replacing an existing file re-use its database record.
     // @todo Do not create a new entity in order to update it. See
     //   https://www.drupal.org/node/2241865.
-    if ($replace == FILE_EXISTS_REPLACE) {
+    if ($replace == FileSystemInterface::EXISTS_REPLACE) {
       $existing_files = \Drupal::entityTypeManager()->getStorage('file')->loadByProperties(['uri' => $uri]);
       if (count($existing_files)) {
         $existing = reset($existing_files);
@@ -192,7 +194,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
     }
     // If we are renaming around an existing file (rather than a directory),
     // use its basename for the filename.
-    elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
+    elseif ($replace == FileSystemInterface::EXISTS_RENAME && is_file($destination)) {
       $file->setFilename($file_system->basename($destination));
     }
 
@@ -225,13 +227,14 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
  * @param int $replace
  *   (optional) The replace behavior when the destination file already exists.
  *   Possible values include:
- *   - FILE_EXISTS_REPLACE: Replace the existing file. If a managed file with
- *     the destination name exists then its database entry will be updated and
- *     $source->delete() called after invoking hook_file_move(). If no database
- *     entry is found, then the source files record will be updated.
- *   - FILE_EXISTS_RENAME: (default) Append _{incrementing number} until the
- *     filename is unique.
- *   - FILE_EXISTS_ERROR: Do nothing and return FALSE.
+ *   - FileSystemInterface::EXISTS_REPLACE: Replace the existing file. If a
+ *     managed file with the destination name exists then its database entry
+ *     will be updated and $source->delete() called after invoking
+ *     hook_file_move(). If no database entry is found, then the source files
+ *     record will be updated.
+ *   - FileSystemInterface::EXISTS_RENAME: (default) Append
+ *     _{incrementing number} until the filename is unique.
+ *   - FileSystemInterface::EXISTS_ERROR: Do nothing and return FALSE.
  *
  * @return \Drupal\file\FileInterface|false
  *   Resulting file entity for success, or FALSE in the event of an error.
@@ -239,7 +242,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
  * @see \Drupal\Core\File\FileSystemInterface::move()
  * @see hook_file_move()
  */
-function file_move(FileInterface $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
+function file_move(FileInterface $source, $destination = NULL, $replace = FileSystemInterface::EXISTS_RENAME) {
   /** @var \Drupal\Core\File\FileSystemInterface $file_system */
   $file_system = \Drupal::service('file_system');
   /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
@@ -263,7 +266,7 @@ function file_move(FileInterface $source, $destination = NULL, $replace = FILE_E
     $file = clone $source;
     $file->setFileUri($uri);
     // If we are replacing an existing file re-use its database record.
-    if ($replace == FILE_EXISTS_REPLACE) {
+    if ($replace == FileSystemInterface::EXISTS_REPLACE) {
       $existing_files = \Drupal::entityTypeManager()->getStorage('file')->loadByProperties(['uri' => $uri]);
       if (count($existing_files)) {
         $existing = reset($existing_files);
@@ -274,7 +277,7 @@ function file_move(FileInterface $source, $destination = NULL, $replace = FILE_E
     }
     // If we are renaming around an existing file (rather than a directory),
     // use its basename for the filename.
-    elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
+    elseif ($replace == FileSystemInterface::EXISTS_RENAME && is_file($destination)) {
       $file->setFilename(\Drupal::service('file_system')->basename($destination));
     }
 
@@ -551,19 +554,20 @@ function file_validate_image_resolution(FileInterface $file, $maximum_dimensions
  * @param int $replace
  *   (optional) The replace behavior when the destination file already exists.
  *   Possible values include:
- *   - FILE_EXISTS_REPLACE: Replace the existing file. If a managed file with
- *     the destination name exists, then its database entry will be updated. If
- *     no database entry is found, then a new one will be created.
- *   - FILE_EXISTS_RENAME: (default) Append _{incrementing number} until the
- *     filename is unique.
- *   - FILE_EXISTS_ERROR: Do nothing and return FALSE.
+ *   - FileSystemInterface::EXISTS_REPLACE: Replace the existing file. If a
+ *     managed file with the destination name exists, then its database entry
+ *     will be updated. If no database entry is found, then a new one will be
+ *     created.
+ *   - FileSystemInterface::EXISTS_RENAME: (default) Append
+ *     _{incrementing number} until the filename is unique.
+ *   - FileSystemInterface::EXISTS_ERROR: Do nothing and return FALSE.
  *
  * @return \Drupal\file\FileInterface|false
  *   A file entity, or FALSE on error.
  *
  * @see file_unmanaged_save_data()
  */
-function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
+function file_save_data($data, $destination = NULL, $replace = FileSystemInterface::EXISTS_RENAME) {
   $user = \Drupal::currentUser();
 
   if (empty($destination)) {
@@ -589,7 +593,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
     // If we are replacing an existing file re-use its database record.
     // @todo Do not create a new entity in order to update it. See
     //   https://www.drupal.org/node/2241865.
-    if ($replace == FILE_EXISTS_REPLACE) {
+    if ($replace == FileSystemInterface::EXISTS_REPLACE) {
       $existing_files = \Drupal::entityTypeManager()->getStorage('file')->loadByProperties(['uri' => $uri]);
       if (count($existing_files)) {
         $existing = reset($existing_files);
@@ -600,7 +604,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
     }
     // If we are renaming around an existing file (rather than a directory),
     // use its basename for the filename.
-    elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
+    elseif ($replace == FileSystemInterface::EXISTS_RENAME && is_file($destination)) {
       $file->setFilename(\Drupal::service('file_system')->basename($destination));
     }
 
@@ -778,10 +782,10 @@ function file_cron() {
  * @param int $replace
  *   (optional) The replace behavior when the destination file already exists.
  *   Possible values include:
- *   - FILE_EXISTS_REPLACE: Replace the existing file.
- *   - FILE_EXISTS_RENAME: (default) Append _{incrementing number} until the
- *     filename is unique.
- *   - FILE_EXISTS_ERROR: Do nothing and return FALSE.
+ *   - FileSystemInterface::EXISTS_REPLACE: Replace the existing file.
+ *   - FileSystemInterface::EXISTS_RENAME: (default) Append
+ *     _{incrementing number} until the filename is unique.
+ *   - FileSystemInterface::EXISTS_ERROR: Do nothing and return FALSE.
  *
  * @return array|\Drupal\file\FileInterface|null|false
  *   An array of file entities or a single file entity if $delta != NULL. Each
@@ -797,7 +801,7 @@ function file_cron() {
  * @see https://www.drupal.org/project/drupal/issues/3069020
  * @see https://www.drupal.org/project/drupal/issues/2482783
  */
-function _file_save_upload_from_form(array $element, FormStateInterface $form_state, $delta = NULL, $replace = FILE_EXISTS_RENAME) {
+function _file_save_upload_from_form(array $element, FormStateInterface $form_state, $delta = NULL, $replace = FileSystemInterface::EXISTS_RENAME) {
   // Get all errors set before calling this method. This will also clear them
   // from $_SESSION.
   $errors_before = \Drupal::messenger()->deleteByType(MessengerInterface::TYPE_ERROR);
@@ -877,10 +881,10 @@ function _file_save_upload_from_form(array $element, FormStateInterface $form_st
  * @param int $replace
  *   (optional) The replace behavior when the destination file already exists.
  *   Possible values include:
- *   - FILE_EXISTS_REPLACE: Replace the existing file.
- *   - FILE_EXISTS_RENAME: (default) Append _{incrementing number} until the
- *     filename is unique.
- *   - FILE_EXISTS_ERROR: Do nothing and return FALSE.
+ *   - FileSystemInterface::EXISTS_REPLACE: Replace the existing file.
+ *   - FileSystemInterface::EXISTS_RENAME: (default) Append
+ *     _{incrementing number} until the filename is unique.
+ *   - FileSystemInterface::EXISTS_ERROR: Do nothing and return FALSE.
  *
  * @return array|\Drupal\file\FileInterface|null|false
  *   An array of file entities or a single file entity if $delta != NULL. Each
@@ -891,7 +895,7 @@ function _file_save_upload_from_form(array $element, FormStateInterface $form_st
  *
  * @todo: move this logic to a service in https://www.drupal.org/node/2244513.
  */
-function file_save_upload($form_field_name, $validators = [], $destination = FALSE, $delta = NULL, $replace = FILE_EXISTS_RENAME) {
+function file_save_upload($form_field_name, $validators = [], $destination = FALSE, $delta = NULL, $replace = FileSystemInterface::EXISTS_RENAME) {
   static $upload_cache;
 
   $all_files = \Drupal::request()->files->get('files', []);
diff --git a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
index 0cb21a44bf0bef9f96a1eb8fa9c4715e9ffc93b2..6979d9c7bd708ebb3e23dcdbeff75b2b91c42aab 100644
--- a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
+++ b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
@@ -265,8 +265,8 @@ public function post(Request $request, $entity_type_id, $bundle, $field_name) {
     $this->validate($file, $validators);
 
     // Move the file to the correct location after validation. Use
-    // FILE_EXISTS_ERROR as the file location has already been determined above
-    // in FileSystem::getDestinationFilename().
+    // FileSystemInterface::EXISTS_ERROR as the file location has already been
+    // determined above in FileSystem::getDestinationFilename().
     try {
       $this->fileSystem->move($temp_file_path, $file_uri, FileSystemInterface::EXISTS_ERROR);
     }
diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
index 5bbf43dfc6c3dc43780a211f240b42a2ce5d5c97..de1a4ff0157ee8606cad301189214b84125706e1 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
@@ -77,7 +77,7 @@ protected function setUp() {
     $file_system = \Drupal::service('file_system');
     // Upload with replace to guarantee there's something there.
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
@@ -153,7 +153,7 @@ public function testHandleExtension() {
     // _file_save_upload_from_form() to only allow ".foo".
     $extensions = 'foo';
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
       'extensions' => $extensions,
     ];
@@ -173,7 +173,7 @@ public function testHandleExtension() {
     $extensions = 'foo ' . $this->imageExtension;
     // Now tell _file_save_upload_from_form() to allow the extension of our test image.
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
       'extensions' => $extensions,
     ];
@@ -191,7 +191,7 @@ public function testHandleExtension() {
 
     // Now tell _file_save_upload_from_form() to allow any extension.
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
       'allow_all_extensions' => TRUE,
     ];
@@ -214,7 +214,7 @@ public function testHandleDangerousFile() {
     // Allow the .php extension and make sure it gets renamed to .txt for
     // safety. Also check to make sure its MIME type was changed.
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload][]' => $file_system->realpath($this->phpfile->uri),
       'is_image_file' => FALSE,
       'extensions' => 'php',
@@ -325,7 +325,7 @@ public function testExistingReplace() {
     /** @var \Drupal\Core\File\FileSystemInterface $file_system */
     $file_system = \Drupal::service('file_system');
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
@@ -343,7 +343,7 @@ public function testExistingError() {
     /** @var \Drupal\Core\File\FileSystemInterface $file_system */
     $file_system = \Drupal::service('file_system');
     $edit = [
-      'file_test_replace' => FILE_EXISTS_ERROR,
+      'file_test_replace' => FileSystemInterface::EXISTS_ERROR,
       'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
diff --git a/core/modules/file/tests/src/Functional/SaveUploadTest.php b/core/modules/file/tests/src/Functional/SaveUploadTest.php
index 274f7aae8207e7ad2a9bcc251454b7c7e5eafe1b..920b4fe139da8c856995a3c5881a64f3eb12d531 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadTest.php
@@ -72,7 +72,7 @@ protected function setUp() {
 
     // Upload with replace to guarantee there's something there.
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
     ];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
@@ -173,7 +173,7 @@ public function testHandleExtension() {
     // file_save_upload() to only allow ".foo".
     $extensions = 'foo';
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
       'extensions' => $extensions,
     ];
@@ -193,7 +193,7 @@ public function testHandleExtension() {
     $extensions = 'foo ' . $this->imageExtension;
     // Now tell file_save_upload() to allow the extension of our test image.
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
       'extensions' => $extensions,
     ];
@@ -211,7 +211,7 @@ public function testHandleExtension() {
 
     // Now tell file_save_upload() to allow any extension.
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
       'allow_all_extensions' => TRUE,
     ];
@@ -232,7 +232,7 @@ public function testHandleDangerousFile() {
     // Allow the .php extension and make sure it gets renamed to .txt for
     // safety. Also check to make sure its MIME type was changed.
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->phpfile->uri),
       'is_image_file' => FALSE,
       'extensions' => 'php',
@@ -339,7 +339,7 @@ public function testExistingRename() {
    */
   public function testExistingReplace() {
     $edit = [
-      'file_test_replace' => FILE_EXISTS_REPLACE,
+      'file_test_replace' => FileSystemInterface::EXISTS_REPLACE,
       'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
     ];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
@@ -356,7 +356,7 @@ public function testExistingReplace() {
    */
   public function testExistingError() {
     $edit = [
-      'file_test_replace' => FILE_EXISTS_ERROR,
+      'file_test_replace' => FileSystemInterface::EXISTS_ERROR,
       'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
     ];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
diff --git a/core/modules/file/tests/src/Kernel/CopyTest.php b/core/modules/file/tests/src/Kernel/CopyTest.php
index 0df63c86b2706c1741bfe7631bb08436afd1d97b..8fe7b10b8412b9f5fa63667697035d7406b67c49 100644
--- a/core/modules/file/tests/src/Kernel/CopyTest.php
+++ b/core/modules/file/tests/src/Kernel/CopyTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\file\Kernel;
 
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\file\Entity\File;
 
 /**
@@ -21,7 +22,7 @@ public function testNormal() {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $result = file_copy(clone $source, $desired_uri, FILE_EXISTS_ERROR);
+    $result = file_copy(clone $source, $desired_uri, FileSystemInterface::EXISTS_ERROR);
 
     // Check the return status and that the contents changed.
     $this->assertTrue($result, 'File copied successfully.');
@@ -52,7 +53,7 @@ public function testExistingRename() {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $result = file_copy(clone $source, $target->getFileUri(), FILE_EXISTS_RENAME);
+    $result = file_copy(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_RENAME);
 
     // Check the return status and that the contents changed.
     $this->assertTrue($result, 'File copied successfully.');
@@ -92,7 +93,7 @@ public function testExistingReplace() {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $result = file_copy(clone $source, $target->getFileUri(), FILE_EXISTS_REPLACE);
+    $result = file_copy(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_REPLACE);
 
     // Check the return status and that the contents changed.
     $this->assertTrue($result, 'File copied successfully.');
@@ -119,8 +120,7 @@ public function testExistingReplace() {
   }
 
   /**
-   * Test that copying over an existing file fails when FILE_EXISTS_ERROR is
-   * specified.
+   * Test that copying over an existing file fails when instructed to do so.
    */
   public function testExistingError() {
     $contents = $this->randomMachineName(10);
@@ -130,7 +130,7 @@ public function testExistingError() {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $result = file_copy(clone $source, $target->getFileUri(), FILE_EXISTS_ERROR);
+    $result = file_copy(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_ERROR);
 
     // Check the return status and that the contents were not changed.
     $this->assertFalse($result, 'File copy failed.');
diff --git a/core/modules/file/tests/src/Kernel/MoveTest.php b/core/modules/file/tests/src/Kernel/MoveTest.php
index b1fe1f7a42dd0e6cf2d02fc2153b502dcf888a5e..db3a46c2be25f6be550dfb5fb83a98959576f715 100644
--- a/core/modules/file/tests/src/Kernel/MoveTest.php
+++ b/core/modules/file/tests/src/Kernel/MoveTest.php
@@ -3,6 +3,7 @@
 namespace Drupal\Tests\file\Kernel;
 
 use Drupal\Component\Render\FormattableMarkup;
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\file\Entity\File;
 
 /**
@@ -22,7 +23,7 @@ public function testNormal() {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $result = file_move(clone $source, $desired_filepath, FILE_EXISTS_ERROR);
+    $result = file_move(clone $source, $desired_filepath, FileSystemInterface::EXISTS_ERROR);
 
     // Check the return status and that the contents changed.
     $this->assertTrue($result, 'File moved successfully.');
@@ -54,7 +55,7 @@ public function testExistingRename() {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $result = file_move(clone $source, $target->getFileUri(), FILE_EXISTS_RENAME);
+    $result = file_move(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_RENAME);
 
     // Check the return status and that the contents changed.
     $this->assertTrue($result, 'File moved successfully.');
@@ -89,7 +90,7 @@ public function testExistingReplace() {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $result = file_move(clone $source, $target->getFileUri(), FILE_EXISTS_REPLACE);
+    $result = file_move(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_REPLACE);
 
     // Look at the results.
     $this->assertEqual($contents, file_get_contents($result->getFileUri()), 'Contents of file were overwritten.');
@@ -119,7 +120,7 @@ public function testExistingReplaceSelf() {
 
     // Copy the file over itself. Clone the object so we don't have to worry
     // about the function changing our reference copy.
-    $result = file_move(clone $source, $source->getFileUri(), FILE_EXISTS_REPLACE);
+    $result = file_move(clone $source, $source->getFileUri(), FileSystemInterface::EXISTS_REPLACE);
     $this->assertFalse($result, 'File move failed.');
     $this->assertEqual($contents, file_get_contents($source->getFileUri()), 'Contents of file were not altered.');
 
@@ -132,8 +133,7 @@ public function testExistingReplaceSelf() {
   }
 
   /**
-   * Test that moving onto an existing file fails when FILE_EXISTS_ERROR is
-   * specified.
+   * Test that moving onto an existing file fails when instructed to do so.
    */
   public function testExistingError() {
     $contents = $this->randomMachineName(10);
@@ -143,7 +143,7 @@ public function testExistingError() {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $result = file_move(clone $source, $target->getFileUri(), FILE_EXISTS_ERROR);
+    $result = file_move(clone $source, $target->getFileUri(), FileSystemInterface::EXISTS_ERROR);
 
     // Check the return status and that the contents did not change.
     $this->assertFalse($result, 'File move failed.');
diff --git a/core/modules/file/tests/src/Kernel/SaveDataTest.php b/core/modules/file/tests/src/Kernel/SaveDataTest.php
index 471193f9fe98a413ce0ff27b81185f1febd3a0d9..346a9f8332e7e0473449373407ccdffa4b304a3d 100644
--- a/core/modules/file/tests/src/Kernel/SaveDataTest.php
+++ b/core/modules/file/tests/src/Kernel/SaveDataTest.php
@@ -3,6 +3,7 @@
 namespace Drupal\Tests\file\Kernel;
 
 use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\file\Entity\File;
 
 /**
@@ -71,7 +72,7 @@ public function testExistingRename() {
     $existing = $this->createFile();
     $contents = $this->randomMachineName(8);
 
-    $result = file_save_data($contents, $existing->getFileUri(), FILE_EXISTS_RENAME);
+    $result = file_save_data($contents, $existing->getFileUri(), FileSystemInterface::EXISTS_RENAME);
     $this->assertTrue($result, 'File saved successfully.');
 
     $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
@@ -101,7 +102,7 @@ public function testExistingReplace() {
     $existing = $this->createFile();
     $contents = $this->randomMachineName(8);
 
-    $result = file_save_data($contents, $existing->getFileUri(), FILE_EXISTS_REPLACE);
+    $result = file_save_data($contents, $existing->getFileUri(), FileSystemInterface::EXISTS_REPLACE);
     $this->assertTrue($result, 'File saved successfully.');
 
     $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
@@ -130,8 +131,8 @@ public function testExistingError() {
     $existing = $this->createFile(NULL, $contents);
 
     // Check the overwrite error.
-    $result = file_save_data('asdf', $existing->getFileUri(), FILE_EXISTS_ERROR);
-    $this->assertFalse($result, 'Overwriting a file fails when FILE_EXISTS_ERROR is specified.');
+    $result = file_save_data('asdf', $existing->getFileUri(), FileSystemInterface::EXISTS_ERROR);
+    $this->assertFalse($result, 'Overwriting a file fails when FileSystemInterface::EXISTS_ERROR is specified.');
     $this->assertEqual($contents, file_get_contents($existing->getFileUri()), 'Contents of existing file were unchanged.');
 
     // Check that no hooks were called while failing.
diff --git a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
index 46281918c87ae6b58a71facf620fa15da221aaf4..34d05c27283f6fe039a07a8af0a1e6bba8ffd872 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
@@ -4,6 +4,7 @@
 
 use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Entity\Entity\EntityViewDisplay;
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\file\Entity\File;
 use Drupal\field\Entity\FieldStorageConfig;
@@ -43,7 +44,7 @@ public function testDefaultImages() {
     for ($i = 1; $i <= 10; $i++) {
       $filename = $this->randomMachineName() . "$i";
       $desired_filepath = 'public://' . $filename;
-      \Drupal::service('file_system')->copy($files[0]->uri, $desired_filepath, FILE_EXISTS_ERROR);
+      \Drupal::service('file_system')->copy($files[0]->uri, $desired_filepath, FileSystemInterface::EXISTS_ERROR);
       $file = File::create(['uri' => $desired_filepath, 'filename' => $filename, 'name' => $filename]);
       $file->save();
     }
diff --git a/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php b/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php
index 59fd3fafed297c9022e7811ec928aca873a0e088..389b4659da4cfd94f91cb9cc3f30427ea804d873 100644
--- a/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php
+++ b/core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php
@@ -187,8 +187,8 @@ public function handleFileUploadForField(FieldDefinitionInterface $field_definit
     }
 
     // Move the file to the correct location after validation. Use
-    // FILE_EXISTS_ERROR as the file location has already been determined above
-    // in FileSystem::getDestinationFilename().
+    // FileSystemInterface::EXISTS_ERROR as the file location has already been
+    // determined above in FileSystem::getDestinationFilename().
     try {
       $this->fileSystem->move($temp_file_path, $file_uri, FileSystemInterface::EXISTS_ERROR);
     }
diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc
index dc8575e34c399fb24d482bc342019c9692afb479..4829363b6be2e297f57d7f2446ef1c4690ae7cc6 100644
--- a/core/modules/locale/locale.batch.inc
+++ b/core/modules/locale/locale.batch.inc
@@ -5,6 +5,7 @@
  * Batch process to check the availability of remote or local po files.
  */
 
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\Url;
 use GuzzleHttp\Exception\RequestException;
 use Psr\Http\Message\RequestInterface;
@@ -293,7 +294,7 @@ function locale_translation_http_check($uri) {
  *   File object if download was successful. FALSE on failure.
  */
 function locale_translation_download_source($source_file, $directory = 'temporary://') {
-  if ($uri = system_retrieve_file($source_file->uri, $directory, FALSE, FILE_EXISTS_REPLACE)) {
+  if ($uri = system_retrieve_file($source_file->uri, $directory, FALSE, FileSystemInterface::EXISTS_REPLACE)) {
     $file = clone($source_file);
     $file->type = LOCALE_TRANSLATION_LOCAL;
     $file->uri = $uri;
diff --git a/core/modules/locale/tests/src/Functional/LocaleExportTest.php b/core/modules/locale/tests/src/Functional/LocaleExportTest.php
index 313c8e173245ad9cdd9c6e28ec01d93c7aafe846..1b0d67e88af869efb3ed5f8fab24ce6a84b1c83d 100644
--- a/core/modules/locale/tests/src/Functional/LocaleExportTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleExportTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\locale\Functional;
 
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Tests\BrowserTestBase;
 
 /**
@@ -33,8 +34,8 @@ protected function setUp() {
     $this->drupalLogin($this->adminUser);
 
     // Copy test po files to the translations directory.
-    \Drupal::service('file_system')->copy(__DIR__ . '/../../../tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
-    \Drupal::service('file_system')->copy(__DIR__ . '/../../../tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
+    \Drupal::service('file_system')->copy(__DIR__ . '/../../../tests/test.de.po', 'translations://', FileSystemInterface::EXISTS_REPLACE);
+    \Drupal::service('file_system')->copy(__DIR__ . '/../../../tests/test.xx.po', 'translations://', FileSystemInterface::EXISTS_REPLACE);
   }
 
   /**
diff --git a/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php b/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
index 6db85764962d987f787aaa7cabb0e434fb20f23c..1005c5c2342cb690ebc270af2a4cf86565ccc4f5 100644
--- a/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Url;
 use Drupal\Core\Database\Database;
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Tests\BrowserTestBase;
 use Drupal\Core\Language\LanguageInterface;
 
@@ -46,8 +47,8 @@ protected function setUp() {
     // Copy test po files to the translations directory.
     /** @var \Drupal\Core\File\FileSystemInterface $file_system */
     $file_system = \Drupal::service('file_system');
-    $file_system->copy(__DIR__ . '/../../../tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
-    $file_system->copy(__DIR__ . '/../../../tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
+    $file_system->copy(__DIR__ . '/../../../tests/test.de.po', 'translations://', FileSystemInterface::EXISTS_REPLACE);
+    $file_system->copy(__DIR__ . '/../../../tests/test.xx.po', 'translations://', FileSystemInterface::EXISTS_REPLACE);
 
     $this->adminUser = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages']);
     $this->adminUserAccessSiteReports = $this->drupalCreateUser(['administer languages', 'translate interface', 'access administration pages', 'access site reports']);
diff --git a/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php
index 0ca705efb15cd8022d148f96007aac2f623747eb..8f50f4ca74a6eb3d08a81bcbf1c44cf251bd5d04 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php
@@ -167,7 +167,8 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
    * @param string $destination
    *   The destination path or URI.
    * @param int $replace
-   *   (optional) FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME.
+   *   (optional) FileSystemInterface::EXISTS_REPLACE (default) or
+   *   FileSystemInterface::EXISTS_RENAME.
    *
    * @return string|bool
    *   File destination on success, FALSE on failure.
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index b6dc4fb101c251389b650e4f9ed416385fd55747..dc1509ab9110938499019b781b6a7b4cfbe282ea 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -1354,10 +1354,10 @@ function system_time_zones($blank = NULL, $grouped = FALSE) {
  *   registered in the database.
  * @param int $replace
  *   Replace behavior when the destination file already exists:
- *   - FILE_EXISTS_REPLACE: Replace the existing file.
- *   - FILE_EXISTS_RENAME: Append _{incrementing number} until the filename is
- *     unique.
- *   - FILE_EXISTS_ERROR: Do nothing and return FALSE.
+ *   - FileSystemInterface::EXISTS_REPLACE: Replace the existing file.
+ *   - FileSystemInterface::EXISTS_RENAME: Append _{incrementing number} until
+ *     the filename is unique.
+ *   - FileSystemInterface::EXISTS_ERROR: Do nothing and return FALSE.
  *
  * @return mixed
  *   One of these possibilities:
diff --git a/core/modules/update/src/Form/UpdateManagerInstall.php b/core/modules/update/src/Form/UpdateManagerInstall.php
index 67e989de8c58379267c98db3b2f5c3125050fd77..681e236ec2dc4fab4ab50fdb9dba770c1c60c14d 100644
--- a/core/modules/update/src/Form/UpdateManagerInstall.php
+++ b/core/modules/update/src/Form/UpdateManagerInstall.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Archiver\ArchiverManager;
 use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\FileTransfer\Local;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -157,7 +158,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
     }
     elseif (!empty($all_files['project_upload'])) {
       $validators = ['file_validate_extensions' => [$this->archiverManager->getExtensions()]];
-      if (!($finfo = file_save_upload('project_upload', $validators, NULL, 0, FILE_EXISTS_REPLACE))) {
+      if (!($finfo = file_save_upload('project_upload', $validators, NULL, 0, FileSystemInterface::EXISTS_REPLACE))) {
         // Failed to upload the file. file_save_upload() calls
         // \Drupal\Core\Messenger\MessengerInterface::addError() on failure.
         return;
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index a2a0ba032f7d5d7ab9b10932cb74ac19c204eeb7..1b02aeffa7a1455952ceb7cc5a9c30afa50c069a 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -38,6 +38,7 @@
 
 use Drupal\Core\Url;
 use Drupal\Core\File\Exception\FileException;
+use Drupal\Core\File\FileSystemInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 
 /**
@@ -226,7 +227,7 @@ function update_manager_file_get($url) {
   $local = $cache_directory . '/' . \Drupal::service('file_system')->basename($parsed_url['path']);
 
   if (!file_exists($local) || update_delete_file_if_stale($local)) {
-    return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE);
+    return system_retrieve_file($url, $local, FALSE, FileSystemInterface::EXISTS_REPLACE);
   }
   else {
     return $local;
diff --git a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
index 95f9b547ce166f14979a51b24705bed2793b6248..376ce1cef0e02fdc926ec86b4ca3d01cf29fd7dd 100644
--- a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php
@@ -156,9 +156,9 @@ public function testFileCreateNewFilepath() {
    *
    * If a file exists, ::getDestinationFilename($destination, $replace) will
    * either return:
-   * - the existing filepath, if $replace is FILE_EXISTS_REPLACE
-   * - a new filepath if FILE_EXISTS_RENAME
-   * - an error (returning FALSE) if FILE_EXISTS_ERROR.
+   * - the existing filepath, if $replace is FileSystemInterface::EXISTS_REPLACE
+   * - a new filepath if FileSystemInterface::EXISTS_RENAME
+   * - an error (returning FALSE) if FileSystemInterface::EXISTS_ERROR.
    * If the file doesn't currently exist, then it will simply return the
    * filepath.
    */
diff --git a/core/tests/Drupal/KernelTests/Core/File/FileSaveDataTest.php b/core/tests/Drupal/KernelTests/Core/File/FileSaveDataTest.php
index b2ba943ef0e9798f566a34e841263e3896d42213..74c2fa6f8a5bcff1acc5600352fee6f0ae1fcfca 100644
--- a/core/tests/Drupal/KernelTests/Core/File/FileSaveDataTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/FileSaveDataTest.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\KernelTests\Core\File;
 
+use Drupal\Core\File\FileSystemInterface;
+
 /**
  * Tests the file_unmanaged_save_data() function.
  *
@@ -21,7 +23,7 @@ public function testFileSaveData() {
     $file_system = \Drupal::service('file_system');
 
     // Provide a filename.
-    $filepath = $file_system->saveData($contents, 'public://asdf.txt', FILE_EXISTS_REPLACE);
+    $filepath = $file_system->saveData($contents, 'public://asdf.txt', FileSystemInterface::EXISTS_REPLACE);
     $this->assertTrue($filepath, 'Unnamed file saved correctly.');
     $this->assertEqual('asdf.txt', \Drupal::service('file_system')->basename($filepath), 'File was named correctly.');
     $this->assertEqual($contents, file_get_contents($filepath), 'Contents of the file are correct.');