Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarongilman/f66b875e14fb54fa28abb41f0bc9882a to your computer and use it in GitHub Desktop.
Save aarongilman/f66b875e14fb54fa28abb41f0bc9882a to your computer and use it in GitHub Desktop.
Box Content Preview Example - Multiple Previews
[[[https://codepen.io/box-platform/pen/xBRLmP]]]
<body>
<div class="preview-container" id="preview1"></div>
<div class="preview-container" id="preview2"></div>
<div class="preview-container" id="preview3"></div>
<div class="preview-container" id="preview4"></div>
</body>
// NOTE: This codepen uses https://codepen.io/box-platform/pen/xBRLmP for static assets and authentication. The token used is a readonly token accessing public data in a demo enterprise.
// How to use this CodePen:
// 1. Get started with Box Platform and create an application: https://developer.box.com/docs/getting-started-box-platform
// 2. Generate an access token using an SDK or use a developer token from https://app.box.com/developers/console/ -> your application -> configuration in the left sidebar -> Generate Developer Token
// 3. Whitelist 'http://s.codepen.io' and 'https://s.codepen.io' in your CORS allowed origins in https://app.box.com/developers/console/ -> your application -> configuration in the left sidebar -> CORS Domains
// 4. Upload a file using a SDK or to your Box account and get a file ID
// 5. Enter your access token below, replacing the existing access token. Replace the file ID with yours from step 4. If you do so, comment out the 'collection' option passed into preview.show().
for (let i = 1; i <= 4; i++) {
const preview = new Box.Preview();
preview.show(configData.FILE_ID, configData.ACCESS_TOKEN, {
container: `#preview${i}`,
showDownload: true
});
}
<script src="https://codepen.io/box-platform/pen/xBRLmP.js"></script>
.preview-container {
display: inline-block;
border: 1px solid #eee;
height: 490px;
width: 24%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment