Giter Site home page Giter Site logo

Comments (1)

GleamTech avatar GleamTech commented on July 17, 2024

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:

//Optional parameters (used for detailed file info, e.g. for generating better cache keys)
documentViewer.Document = new StreamFileProvider(
    "SomeFolder/SomeFile.ext", 
    yourStream,
    yourFileDateModified,
    yourFileSize //Provide size only if your stream is not seekable
);
//Optional parameters (used for detailed file info, e.g. for generating better cache keys)
documentViewer.Document = new MemoryFileProvider(
    "SomeFolder/SomeFile.ext", 
    yourMemoryStream,
    yourFileDateModified
);
//Optional parameters (used for detailed file info, e.g. for generating better cache keys)
documentViewer.Document = new MemoryFileProvider(
    "SomeFolder/SomeFile.ext", 
    yourByteArray,
    yourFileDateModified
);

from documentultimate.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.