Box Content Preview use specific version
AnsweredI 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.
-
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!
-
are you looking for something like this?
-
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' } }); -
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?
-
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 } } });
Please sign in to leave a comment.
Comments
10 comments