Skip to main content
Question

Box Content Preview use specific version

  • May 22, 2025
  • 10 replies
  • 22 views

Forum|alt.badge.img

I was hoping that I was doing something incorrectly but it doesn't look supported using this UI Element. Basically I want to pass a version as well as file ID to the element and have that render, however even though you can pass an object with that in, it always gets the latest version from the API?

 

Can't imagine that I'm the only one with that idea and don't really want to write a custom implementation.

10 replies

Forum|alt.badge.img

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! 


Forum|alt.badge.img

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


Forum|alt.badge.img

 are you looking for something like this


Forum|alt.badge.img

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' } });

 


Forum|alt.badge.img

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


Forum|alt.badge.img

hi ,

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


Forum|alt.badge.img

I believe it should work!  


Forum|alt.badge.img
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? 

Forum|alt.badge.img

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
        }
    }
});

Forum|alt.badge.img

 Thank you it worked!