Welcome to the new Box Support website. Check out all the details here on what’s changed.

Box Content Preview use specific version

Answered
New post

Comments

10 comments

  • Kourtney

    Hello : 

     

    Thanks so much for using our platform and development forum! 

     

    Here's an example of how to accomplish this: 

     

    var preview = new Box.Preview();
    preview.show(FILE_ID, ACCESS_TOKEN, {
    container: '.preview-container',
    showDownload: true,
    fileOptions: {
    fileVersionId: '199928394633'
    }
    });

     

    There is documentation you can refer to here as well! 

    0
    Comment actions Permalink
  • NickUK

    Thanks . Doesn't look like it would work for multiple files (carousel)?

    0
    Comment actions Permalink
  • Kourtney

     are you looking for something like this

    0
    Comment actions Permalink
  • jpress

    Hi NickUK, If you're referring to multiple files for one instance of preview, you can specify versions like so (1,2,3,4 are file IDs):

    Documentation can be found here: https://github.com/box/box-content-preview#parameters--options

     

    var preview = new Box.Preview();
    preview.show(FILE_ID, ACCESS_TOKEN, {
    container: '.preview-container',
    collection: ['1', '2', '3', '4'] showDownload: true, fileOptions: { '1': { fileVersionId: '12345' }, '2': { fileVersionId: '54321' }, '3': { fileVersionId: '32145' }, '4': { fileVersionId: '32145' } });

     

    0
    Comment actions Permalink
  • dysp

    Does this work with the free developer's version of Box?

    0
    Comment actions Permalink
  • jpress

    hi ,

    Yes, you are able to use the Preview SDK with a developer account. 

    0
    Comment actions Permalink
  • Kourtney

    I believe it should work!  

    0
    Comment actions Permalink
  • dysp
    this.preview.show(this.props.contentId, this.props.boxToken, {
    container: '.documentPreviewArea',
    header: 'none',
    fileOptions: {
    fileVersionId: this.state.currentVersionId
    }
    });
     
    I'm trying to show preview version using this code, but it keeps showing the current version of the document.
    Do I have to reinitialize the box client or the box preview? 
    0
    Comment actions Permalink
  • jpress

    You shouldn't need to reinit preview, but you will need to map from file ID to file version ID, so we know which version you want to use for which file.

     

     

    I think in your example you would need to do the following:

    this.preview.show(this.props.contentId, this.props.boxToken, {
        container: '.documentPreviewArea',
        header: 'none',
        fileOptions: {
            this.props.contentId: {
                fileVersionId: this.state.currentVersionId
            }
        }
    });
    0
    Comment actions Permalink
  • dysp

     Thank you it worked!

    0
    Comment actions Permalink

Please sign in to leave a comment.