Since v6.4 we are using FileProvider API. There are many built-in file providers e.g. FileSystemFileProvider, UrlFileProvider, DataUrlFileProvider, StreamFileProvider, MemoryFileProvider, DatabaseFileProvider, AssemblyResourceFileProvider, TemporaryFileProvider.
For generating the cache key, to uniquely identify a document file, we use a string combination of file extension, file size and file date, this way cache collisions do not occur and we can resuse the cached file even if the file name before extension is changed (file1.docx and file2.docx have same cache key because it's still the same document according to file extension, file size and file date).
File providers like FileSystemFileProvider (a file on disk, on Amazon S3, on Azure) can provide file size and file date automatically however some file providers will not have this knowledge, e.g. StreamFileProvider, MemoryFileProvider (how could they know date modified of your data in a byte array or a stream?).
So for this purpose, these kind of providers have an additional property or constructor argument named DateModified and/or Size. You need to specify these to ensure you uniquely identify a document:
//Setting a MemoryFileProvider instance,
//to connect to a file in a byte array (byte[]) or a MemoryStream:
//Optional parameter dateModified: used for detailed file info, e.g. for generating better cache keys.
documentViewer.Document = new MemoryFileProvider(
"Document.docx", //file can also be set as a relative path "SomeFolder/Document.docx".
yourByteArray,
yourFileDateModified //Provide dateModified to prevent cache key conflicts.
);
documentViewer.Document = new MemoryFileProvider(
"Document.docx", //file can also be set as a relative path "SomeFolder/Document.docx".
yourMemoryStream,
yourFileDateModified //Provide dateModified to prevent cache key conflicts.
);
//Setting a StreamFileProvider instance,
//to connect to a file in a Stream:
//Optional parameters dateModified and size: used for detailed file info, e.g. for generating better cache keys.
documentViewer.Document = new StreamFileProvider(
"Document.docx", //file can also be set as a relative path "SomeFolder/Document.docx".
yourStream,
yourFileDateModified, //Provide dateModified to prevent cache key conflicts.
yourFileSize //Provide size only if your stream is not seekable to prevent cache key conflicts.
);