- Direct embed: A standard HTML
<iframe>component with a custom embed link. - Customized previewer: A fully customized preview widget using Box UI Elements.
Direct Embed (iframe)
The direct embed link provides limited options to customize the preview
experience in your application. Due to the light-weight nature of the method,
the API doesn’t give you options to respond to client-side actions such as
scrolling in the case of documents, play/pause interactivity for videos,
rotating an image, etc.
There are two steps to create a direct <iframe> embed for Box View:
- Generate an embed URL for the file
- Add the embed URL to an
<iframe>
Generate an embed URL for the file
To create a public file preview URL for a file that was uploaded to the App Token application, you may either use a direct SDK method or make the request directly to the APIs.When generating the embed URL directly from the APIs, use the
Get File Information endpoint and request
expiring_embed_link via the fields parameter.Add the embed URL to an <iframe>
Within the HTML of your application, create an iframe elements with the src
attribute set to generated embed URL.
Customized Previewer (UI Elements)
To leverage advanced preview customization and event handling capabilities, use the Box UI Preview Element. To set up the Preview Element, start by installing the required components.Install Box Elements and Preview
FILE_ID: The ID of the file uploaded to the App Token application, which can be obtained from the object returned when uploading the file.ACCESS_TOKEN: The primary Access Token set up when configuring the application or a downscoped version of the token.
