diff --git a/src/Mime-Detective/Analyzers/ZipFileAnalyzer.cs b/src/Mime-Detective/Analyzers/ZipFileAnalyzer.cs
index 3cc845a..1d1f3ef 100644
--- a/src/Mime-Detective/Analyzers/ZipFileAnalyzer.cs
+++ b/src/Mime-Detective/Analyzers/ZipFileAnalyzer.cs
@@ -24,7 +24,8 @@ public FileType Search(in ReadResult readResult)
if (readResult.Source is null)
{
- mStream = new MemoryStream(readResult.Array, 0, readResult.ReadLength);
+ //this should be the length of the array passed via ReadResult
+ mStream = new MemoryStream(readResult.Array, 0, readResult.Array.Length);
locallyCreatedStream = true;
}
else
diff --git a/src/Mime-Detective/Helpers/ReadResult.cs b/src/Mime-Detective/Helpers/ReadResult.cs
index b0899d8..dbcb193 100644
--- a/src/Mime-Detective/Helpers/ReadResult.cs
+++ b/src/Mime-Detective/Helpers/ReadResult.cs
@@ -14,8 +14,17 @@ namespace MimeDetective
///
public readonly struct ReadResult : IDisposable
{
+ ///
+ /// Use Array.Length instead of ReadLength when you are refering to the whole file and source is null
+ ///
public readonly byte[] Array;
+
public readonly Stream Source;
+
+ ///
+ /// This is meant to be the int result of Stream.Read, it should cap at 560
+ /// Do not use when referring to the whole file
+ ///
public readonly int ReadLength;
public bool IsArrayRented { get; }
diff --git a/src/Mime-Detective/Mime-Detective.csproj b/src/Mime-Detective/Mime-Detective.csproj
index 994f1b1..4b4f737 100644
--- a/src/Mime-Detective/Mime-Detective.csproj
+++ b/src/Mime-Detective/Mime-Detective.csproj
@@ -18,8 +18,8 @@
0.0.6.0
0.0.6.0
- See beta1 PR
- 0.0.6.0-beta1
+ See beta2 PR
+ 0.0.6.0-beta2
true
diff --git a/test/Mime-Detective.Tests/Data/Documents/test.xlsx b/test/Mime-Detective.Tests/Data/Documents/test.xlsx
new file mode 100644
index 0000000..33639ea
Binary files /dev/null and b/test/Mime-Detective.Tests/Data/Documents/test.xlsx differ
diff --git a/test/Mime-Detective.Tests/Tests/TypeExtensions.cs b/test/Mime-Detective.Tests/Tests/TypeExtensions.cs
index 17cfedd..99d7fdf 100644
--- a/test/Mime-Detective.Tests/Tests/TypeExtensions.cs
+++ b/test/Mime-Detective.Tests/Tests/TypeExtensions.cs
@@ -345,5 +345,14 @@ public async Task StreamIsNotDisposedAfterReadingZipFileTypeAsync()
fileStream.Dispose();
}
+
+ [Fact]
+ public void CanReadZipFileFromByteArray()
+ {
+ var result = File.ReadAllBytes("./data/Documents/test.xlsx").GetFileType();
+
+ Assert.NotNull(result);
+ Assert.Equal(MimeTypes.EXCELX, result);
+ }
}
}