Last active
January 19, 2018 16:12
-
-
Save birm/501761572a3d7e7d6e20db3829f89834 to your computer and use it in GitHub Desktop.
This file contains 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 rp = require('request-promise'); | |
var fs = require('fs'); | |
// use https://developer.box.com/v2.0/docs/the-box-file-picker | |
// options to get file | |
function download_file(url) = | |
return { | |
method: 'GET', | |
uri: url, | |
body: { | |
some: 'payload' | |
} | |
}; | |
// handler should call this once per file | |
app.get('/boxFile/:fileId', function(req, res) { | |
res.send("Requesting " + req.params.fileId); | |
// get the box info | |
rp(download_file(req.params.url)) | |
.then(function(fileContent) { | |
var file = fs.createWriteStream(req.params.name); | |
file.write(parsedBody); | |
wstream.end(); | |
}) | |
.catch(function(err) { | |
// failed | |
}); | |
}); |
This file contains 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
<html> | |
<script type="text/javascript" src="https://cdn01.boxcdn.net/js/static/select.js"></script> | |
<div id="box-select" data-link-type="YOUR_LINK_TYPE" data-multiselect="YOUR_MULTISELECT" data-client-id="YOUR_CLIENT_ID"></div> | |
<script> | |
$(document).ready(function() { | |
var boxSelect = new BoxSelect(); | |
// Register a success callback handler | |
boxSelect.success(function(response) { | |
console.log(response); | |
}); | |
// Register a cancel callback handler | |
boxSelect.cancel(function() { | |
console.log("The user clicked cancel or closed the popup"); | |
}); | |
}); | |
</script> | |
</html> |
This file contains 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
<html> | |
<script type="text/javascript" src="https://cdn01.boxcdn.net/js/static/select.js"></script> | |
<script> | |
// config box | |
var options = { | |
clientId: YOUR_CLIENT_ID, | |
linkType: YOUR_LINK_TYPE, | |
multiselect: YOUR_MULTISELECT | |
}; | |
var boxSelect = new BoxSelect(options); | |
// Register a success callback handler | |
boxSelect.success(function(response) { | |
console.log(response); | |
// for file in files | |
// use box upload api (other file in this gist) | |
// register in imageloader | |
}); | |
// Register a cancel callback handler | |
boxSelect.cancel(function() { | |
console.log("The user clicked cancel or closed the popup"); | |
}); | |
// TODO make respond to something | |
boxSelect.launchPopup(); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment