4

Looking for a way to get the embed code for Box files via the API.

We have integrated Box in our app and the new embedded file/folder viewer is awesome. I'd love to give people the option to view their files/folder within our app via the embed option but need a way to get the embed code

e.g: https://www.box.com/embed/{file reference}.swf

Thanks for any info,

Dan.

rposborne
  • 802
  • 8
  • 17
CFDan
  • 43
  • 1
  • 3

4 Answers4

4

EDIT: v2 Folder Embed (requires User to be logged in)

<iframe 
src="https://box.com/embed_widget/000000000000/files/0/f/#{@folder.id}?view=expanded&sort=name&direction=ASC&theme=blue" 
width="100%" 
height="800" 
frameborder="0">
</iframe>

The Folder Embed Code does not appear to be currently supported.

See Comments from the Dev Team at the bottom of this post http://developers.blog.box.com/2012/10/11/even-more-v2-updates/

rposborne
  • 802
  • 8
  • 17
2

I am currently using v1 API CreateFileEmbed http://developers.box.net/w/page/50509454/create_file_embed

Update [Sep 2013]

Box has released a public beta of View API at http://developers.box.com/view/

This is another HTML5 viewer for.

MikeLim
  • 1,189
  • 1
  • 9
  • 11
1

Box documentation and support is horrible. Here's what I've figured out:

# given you have your box file in a variable named "file":

result = file.api.file_embed(file.id) # this may throw Box::Api::NotShared
embed_html = result['file_embed_html'] if result.respond_to?(:[])

Unfortunately, you'll have to make sure the file is publicly shared first. There's apparently no way to do private shares in the API, from what I've found, except via email (wtf?).

For completeness, shares can be done via the api like so: (note the file.unshare method is [at the time of writing] broken, thus the call through file.api)

file.share_public
file.api.unshare_public(file.type, file.id)
Steven Soroka
  • 19,404
  • 4
  • 52
  • 40
0

Maybe this is old, but, This steps work for me.

First, share the file or folder with the api, next, extract the shared_link and later join with the embed url (https://app.box.com/embed_widget/000000000000/s/SHARED_LINK_VALUE).

See: Create shared foldersCreate shared filesEmbed files or folders

Oscar Romero
  • 159
  • 2
  • 11