diff --git a/core/lib/Drupal/Core/Archiver/Zip.php b/core/lib/Drupal/Core/Archiver/Zip.php
index 74f6105929..1bd4dd0dcc 100644
--- a/core/lib/Drupal/Core/Archiver/Zip.php
+++ b/core/lib/Drupal/Core/Archiver/Zip.php
@@ -23,12 +23,15 @@ class Zip implements ArchiverInterface {
    *   The full system path of the archive to manipulate. Only local files
    *   are supported. If the file does not yet exist, it will be created if
    *   appropriate.
+   * @param int $flags
+   *   (optional) The mode to use to open the archive. Defaults to create the
+   *   archive if it does not exist.
    *
    * @throws \Drupal\Core\Archiver\ArchiverException
    */
-  public function __construct($file_path) {
+  public function __construct($file_path, $flags = \ZipArchive::CREATE) {
     $this->zip = new \ZipArchive();
-    if ($this->zip->open($file_path) !== TRUE) {
+    if ($this->zip->open($file_path, $flags) !== TRUE) {
       throw new ArchiverException("Cannot open '$file_path'");
     }
   }
diff --git a/core/tests/Drupal/FunctionalTests/Core/Archiver/ZipTest.php b/core/tests/Drupal/FunctionalTests/Core/Archiver/ZipTest.php
new file mode 100644
index 0000000000..262fd94d3f
--- /dev/null
+++ b/core/tests/Drupal/FunctionalTests/Core/Archiver/ZipTest.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Drupal\FunctionalTests\Core\Archiver;
+
+use Drupal\Core\Archiver\Zip;
+use Drupal\Core\File\FileSystemInterface;
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * @coversDefaultClass \Drupal\Core\Archiver\Zip
+ * @group zip
+ */
+class ZipTest extends BrowserTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $defaultTheme = 'stark';
+
+  /**
+   * Tests that the Zip archive is created if it does not exist.
+   */
+  public function testCreateArchive() {
+    // Create a temporary file that can be added to the archive.
+    $filename = \Drupal::service('file_system')->getTempDirectory() . '/' . $this->randomMachineName();
+    \Drupal::service('file_system')->saveData('llama', $filename, FileSystemInterface::EXISTS_REPLACE);
+
+    // ZipArchive::open() does not support the temporary stream wrapper, so we
+    // have to get the path to the temporary folder.
+    $archiveFilename = \Drupal::service('file_system')->getTempDirectory() . '/' . $this->randomMachineName() . '.zip';
+    $zip = new Zip($archiveFilename);
+    $zip->add($filename);
+
+    // Close the archive and make sure it is written to disk.
+    $this->assertTrue($zip->getArchive()->close(), 'Successfully closed archive.');
+    $this->assertFileExists($archiveFilename, 'Archive is automatically created if the file does not exist.');
+  }
+}
