Skip to content

Instantly share code, notes, and snippets.

@mingliangguo
Created August 3, 2016 02:45
Show Gist options
  • Save mingliangguo/3acd90625ff850309ce8bbc613598f1c to your computer and use it in GitHub Desktop.
Save mingliangguo/3acd90625ff850309ce8bbc613598f1c to your computer and use it in GitHub Desktop.
An even simpler version to get box thumbnail URL (or any other binary content)
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.box.com/2.0/files/76537235577/thumbnail.png?min_height=150&min_width=150", true);
xhr.setRequestHeader("Authorization", "Bearer your_access_token");
xhr.responseType = "blob";
xhr.onload = function(e) {
if (this.status == 200) {
var blob = xhr.response;
var url = URL.createObjectURL(xhr.response);
document.getElementById("preview").src = url;
}
};
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment