Answers.Body: <p>I'm responsible for an attempt to improve this error message, see <a href="https://github.com/IDPF/epubcheck/pull/497" rel="nofollow">https://github.com/IDPF/epubcheck/pull/497</a> for details. Essentially your Zip packer puts some application or operating system specific stuff into the file, which breaks EPUB mimetype magic number support.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-08T21:02:02.837Z
Answers.Text: Use the `zip -X` flag to exclude the extra OS flags, which makes epubcheck stop complaining about the mimetype file.
Answers.UserDisplayName: bjnord
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-28T22:02:46.350Z
Answers.Text: @bjnord Although your comment is irrelevant to the OP's case (C#) it was very helpful for the `zip` command to fix the OP's problem. Thanks.
Answers.UserDisplayName: maliayas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-12T17:22:28.023Z
Answers.LastActivityDate: 2016-01-12T17:37:46.410Z
Answers.LastEditDate: 2016-01-12T17:37:46.410Z
Answers.UserDisplayName: skreutzer
Answers.Body: <p>Ive also had some problems with compression of the mimetype file. What I ended up doing was adding the entry myself from a byte[].</p>
  
  <pre><code>using (ZipOutputStream zs = new ZipOutputStream(pathTemp + ".epub"))
   {
    var o = zs.PutNextEntry("mimetype");
    o.CompressionLevel = CompressionLevel.None;
    byte[] mimetype  = System.Text.Encoding.ASCII.GetBytes("application/epub+zip");
    zs.Write(mimetype, 0, mimetype.Length);
   }
  
  using (ZipFile zip = new ZipFile(pathTemp + ".epub"))
   {
    zip.RemoveSelectedEntries("*.*");
    zip.AddDirectory(pathTemp + "\\content", "content");
    zip.AddDirectory(pathTemp + "\\META-INF", "META-INF");
    zip.Save();
   }
  </code></pre>
  
  <p>This should fix it for you.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-26T13:45:15.673Z
Answers.LastActivityDate: 2015-11-26T13:45:15.673Z
Answers.UserDisplayName: Morne
Body: <p>I am using the C# library DotNetZip (Ionic.Zip and Ionic.Zlib) to generate an ebook from a directory. Directory looks like this:</p>
  
  <pre><code>BookName
  |
  |___content/
  |       images/
  |       css/
  |       (html pages, .ops, .ncx)
  |
  |___META-INF/
  |       container.xml
  |
  |___mimetype
  </code></pre>
  
  <p>The code to generate the archive looks like this:</p>
  
  <pre><code>using (ZipFile zip = new ZipFile(pathTemp + ".epub"))
  {
      zip.RemoveSelectedEntries("*.*");
      zip.AddFile(mimetype, "").CompressionLevel = CompressionLevel.None;
      zip.AddDirectory(pathTemp + "\\content", "content");
      zip.AddDirectory(pathTemp + "\\META-INF", "META-INF");
      zip.Save();
  }
  </code></pre>
  
  <p>When I run it through the <a href="http://validator.idpf.org/" rel="nofollow noreferrer">EPUB Validator</a>, it throws this error:</p>
  
  <blockquote>
    <p>The mimetype file has an extra field of length 36. The use of the extra field feature of the ZIP format is not permitted for the mimetype file.</p>
  </blockquote>
  
  <p>I'm not compressing the mimetype file, so I don't know what is happening.</p>
  
  <p><strong>UPDATE</strong>: This problem has been solved; see the solution <a href="https://stackoverflow.com/a/33726439/1982313">here</a>.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-28T01:29:39.410Z
Comments.Text: This problem has been solved - see the solution [here](http://stackoverflow.com/a/33726439/1982313).
Comments.UserDisplayName: zuddsy
Tags: <epub><epubcheck>
Title: The mimetype file has an extra field of length n. The use of the extra field feature of the ZIP format is not permitted for the mimetype file
UserDisplayName: zuddsy
ThreadText: # The mimetype file has an extra field of length n. The use of the extra field feature of the ZIP format is not permitted for the mimetype file
  
  (Asked by: username_0 on 2015-11-15)
  
  I am using the C# library DotNetZip (Ionic.Zip and Ionic.Zlib) to generate an ebook from a directory. Directory looks like this:
  BookName
  |
  |___content/
  |       images/
  |       css/
  |       (html pages, .ops, .ncx)
  |
  |___META-INF/
  |       container.xml
  |
  |___mimetype
  
  The code to generate the archive looks like this:
  using (ZipFile zip = new ZipFile(pathTemp + ".epub"))
  {
      zip.RemoveSelectedEntries("*.*");
      zip.AddFile(mimetype, "").CompressionLevel = CompressionLevel.None;
      zip.AddDirectory(pathTemp + "\\content", "content");
      zip.AddDirectory(pathTemp + "\\META-INF", "META-INF");
      zip.Save();
  }
  
  When I run it through the EPUB Validator, it throws this error:
  
  The mimetype file has an extra field of length 36. The use of the extra field feature of the ZIP format is not permitted for the mimetype file.
  
  I'm not compressing the mimetype file, so I don't know what is happening.
  UPDATE: This problem has been solved; see the solution here.
  
  **Tags:** epub, epubcheck
  
  > **Comments:**
  > **username_0**: This problem has been solved - see the solution [here](http://stackoverflow.com/a/33726439/1982313).  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-01-12. Score: 1
  
  I'm responsible for an attempt to improve this error message, see <https://github.com/IDPF/epubcheck/pull/497> for details. Essentially your Zip packer puts some application or operating system specific stuff into the file, which breaks EPUB mimetype magic number support.
  
  > **Comments:**
  > **username_2**: Use the `zip -X` flag to exclude the extra OS flags, which makes epubcheck stop complaining about the mimetype file.  
  > **username_3**: @username_2 Although your comment is irrelevant to the OP's case (C#) it was very helpful for the `zip` command to fix the OP's problem. Thanks.  
  
  ---
  
  ### Answer by username_4 on 2015-11-26. Score: 0
  
  Ive also had some problems with compression of the mimetype file. What I ended up doing was adding the entry myself from a byte[].
  using (ZipOutputStream zs = new ZipOutputStream(pathTemp + ".epub"))
   {
    var o = zs.PutNextEntry("mimetype");
    o.CompressionLevel = CompressionLevel.None;
    byte[] mimetype  = System.Text.Encoding.ASCII.GetBytes("application/epub+zip");
    zs.Write(mimetype, 0, mimetype.Length);
   }
  
  using (ZipFile zip = new ZipFile(pathTemp + ".epub"))
   {
    zip.RemoveSelectedEntries("*.*");
    zip.AddDirectory(pathTemp + "\\content", "content");
    zip.AddDirectory(pathTemp + "\\META-INF", "META-INF");
    zip.Save();
   }
  
  This should fix it for you.
  
  
  ---
  
  