-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for GetVersions #570
Labels
Comments
Thanks for the request - we're planning on implementing this before the end of the month. |
Thank you for the update. I have a follow up question. We are evaluating to integrate box viewer. Is there a plan to support viewing of different versions of a file within the box viewer. |
tonyjin
pushed a commit
to tonyjin/box-content-preview
that referenced
this issue
Feb 3, 2018
This patch adds support for previewing non-current file versions. Specify the file version like so: ``` const preview = new Box.Preview(); preview.show(FILE_ID_1, ACCESS_TOKEN, { fileOptions: { [FILE_ID_1]: { fileVersionId: FILE_VERSION_ID_1 } } }); ``` In this patch, we start caching file objects by both file ID and by file version ID, distinguishing between the two with a 'file_' or 'file_version_' prefix as the key to the cache. This allows us to be backwards-compatible and show the current file version if no file version ID is passed in, while always allowing a cached entry of a current version to be overriden when you preview a non-current file version. We abstract this logic to file.js, and rely on the helper methods cacheFile(), uncacheFile(), and getCachedFile() to interact with file objects and the cache. This patch also enables prefetching of files that were previously cached by file ID or file version ID. To support previews of file versions, we introduce a new Preview option `fileOptions`, which allows us to specific individual options by file ID. This is needed instead of just passing in a `fileVersionId` opion since we support collections. Having this mapping of file ID to file options on that file ID allows us to specify file verison IDs for any number of file IDs to preview and can also be extended to support other file-level options in the future. Example of collection + file version support together: ``` const preview = new Box.Preview(); preview.show(FILE_ID_1, ACCESS_TOKEN, { collection: [FILE_ID_1, FILE_ID2], fileOptions: { [FILE_ID_1]: { fileVersionId: FILE_VERSION_ID_1 }, [FILE_ID_2]: { fileVersionId: FILE_VERSION_ID_2 } } }); ``` Caveats: - You cannot pass in the current file version ID as an option since the Box API will fail when you make a get file version info API call for the current version - Preview events do not distinguish between file versions, so a preview of a previous file version will be simply logged as a preview of a file ID This resolves box#570.
tonyjin
added a commit
that referenced
this issue
Feb 3, 2018
This patch adds support for previewing non-current file versions. Specify the file version like so: ``` const preview = new Box.Preview(); preview.show(FILE_ID_1, ACCESS_TOKEN, { fileOptions: { [FILE_ID_1]: { fileVersionId: FILE_VERSION_ID_1 } } }); ``` In this patch, we start caching file objects by both file ID and by file version ID, distinguishing between the two with a 'file_' or 'file_version_' prefix as the key to the cache. This allows us to be backwards-compatible and show the current file version if no file version ID is passed in, while always allowing a cached entry of a current version to be overriden when you preview a non-current file version. We abstract this logic to file.js, and rely on the helper methods cacheFile(), uncacheFile(), and getCachedFile() to interact with file objects and the cache. This patch also enables prefetching of files that were previously cached by file ID or file version ID. To support previews of file versions, we introduce a new Preview option `fileOptions`, which allows us to specific individual options by file ID. This is needed instead of just passing in a `fileVersionId` opion since we support collections. Having this mapping of file ID to file options on that file ID allows us to specify file verison IDs for any number of file IDs to preview and can also be extended to support other file-level options in the future. Example of collection + file version support together: ``` const preview = new Box.Preview(); preview.show(FILE_ID_1, ACCESS_TOKEN, { collection: [FILE_ID_1, FILE_ID2], fileOptions: { [FILE_ID_1]: { fileVersionId: FILE_VERSION_ID_1 }, [FILE_ID_2]: { fileVersionId: FILE_VERSION_ID_2 } } }); ``` Caveats: - You cannot pass in the current file version ID as an option since the Box API will fail when you make a get file version info API call for the current version - Preview events do not distinguish between file versions, so a preview of a previous file version will be simply logged as a preview of a file ID This resolves #570.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any way to use getVersions API, that user can switch between versions of a particular file?
The text was updated successfully, but these errors were encountered: