Created
August 3, 2016 02:45
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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