Skip to content

Instantly share code, notes, and snippets.

@DavidLiedle
Last active November 29, 2018 14:42
Show Gist options
  • Save DavidLiedle/f312705763ac3023f31abfe50403f2a6 to your computer and use it in GitHub Desktop.
Save DavidLiedle/f312705763ac3023f31abfe50403f2a6 to your computer and use it in GitHub Desktop.
Upload an image to filestack, get properly formatted markdown to link to the image
<html>
<head>
<title>Markdown From Filestack Uploads Example</title>
<script src="https://static.filestackapi.com/filestack-js/1.x.x/filestack.min.js"
data-cfasync="false"></script>
<script>
var apikey = 'MYKEYGOESHERE';
var docResponse;
window.addEventListener('DOMContentLoaded', function(){
var client = filestack.init(apikey);
client.picker({
"displayMode": "inline",
"container": "fsuploaderdiv",
"accept": [
"image/*"
],
"uploadInBackground": false,
onFileUploadFinished: function(response){
docResponse = response;
var docFileHandle = response.handle;
var docFileName = response.filename;
console.log(response.handle);
document.getElementById('doreadout').innerHTML = "<h3>!["+docFileName+"](https://cdn.filestackcontent.com/"+docFileHandle+")</h3>";
}
}).open();
});
</script>
<style>
#fsuploaderdiv {
width: 80%;
}
#sitepreview {
width: 40%;
}
</style>
</head>
<body>
<h1>Filestack Uploader</h1>
<h2>Upload:</h2>
<div id="fsuploaderdiv"></div>
<h2>Markdown-formatted links appear here upon upload:</h2>
<div id="doreadout"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment