Solution Builder API

Basic Uploader JavaScript Settings

10min
overview for background information, see implementation details docid 42txky0k3olytswsglysh the basic uploader provides a standard user interface and publishing options using a push or put request to upload the recorded video to your backend after the user completes a recording, they will see an optional form to enter a title and/or description for their recording and an "upload" button to start the upload when the user clicks the "upload" button, the screenpal application will make a request to your backend to the url provided in the basicupload request url property using a post request to send any title/description if not collecting title/description, a get request is made "basicupload request url" "http // /myurlprovider" the response from the myurlprovider script must be a single line of text with a url where the actual mp4 video should be post (or put ) for example, if you were using the s3 amazon example below, then the response returns a pre signed amazon s3 url where permissions have be granted to allow the post http //s3 amazonaws com/ /basicupload mp4?awsaccesskeyid=actual amazon key would be here once the screenpal application has this final url, it will make a post (or put ) request with the body of the request being the mp4 file the body is not encoded (like form data from a browser), but a raw mp4 file take a look at the full list of basic uploader properties docid\ s0ksaqafgnpfvbpnwmsla to see how to customize branding and message strings in the screenpal recorder and editor amazon s3 upload example here is an example php script that you can use to sign a url and upload directly to amazon s3 to use this script you would set the following properties when launching "basicupload request url" "http // /basicuploads3upload php", "basicupload post method" "put", "basicupload post extraheaders 1" "x amz acl\ public read", in this case we also need an extra property to set an additional header which is sent to amazon s3 with the put request to mark that this mp4 is publicly readable here's an example basicuploads3upload php which creates a signed url that we can use to put the mp4 file on amazon s3 \<?php // requires this php library (https //pear php net/package/crypt hmac) require once('crypt/hmac php'); // if you are using the title/desc options then this request will be a post and have these $title = $ post\['title']; $desc = $ post\['description']; // the result of this request must be a single string with the real url to put the mp4 video file // in this example we are going to put to s3 bucket and folder echo createurl("bucket/folder/video name mp4","put","video/mp4"); // // functions to create the signed url to put in amazon s3 button // function createurl($object, $method, $contenttype) { $s3 url = "http //s3 amazonaws com/"; $accessidkey = "your s3 public key"; $accessidsecret = "your s3 private key"; $expires = time() + 120; // they have 1 minutes to do the upload else this url will expire // note this will upload video with public read so you can stream from the bucket $stringtosign = "$method\n\n$contenttype\n$expires\nx amz acl\ public read\n/$object"; $hasher =& new crypt hmac($accessidsecret, "sha1"); $sig = urlencode(hex2b64($hasher >hash($stringtosign))); return "$s3 url/$object?awsaccesskeyid=$accessidkey\&expires=$expires\&signature=$sig"; } function hex2b64($str) { $raw = ''; for ($i=0; $i < strlen($str); $i+=2) { $raw = chr(hexdec(substr($str, $i, 2))); } return base64 encode($raw); } ?> save on server upload example the following example uses php to read the raw input stream of the post request and writes it to a local file to use this script you'd set the following properties when launching "basicupload request url" "http // /basicuploadsaveupload php", the basicuploadsaveupload php script below reads the mp4 file from the request input stream and saves to a local file in /tmp , but it can be placed anywhere on the server that you have write permission \<?php / data comes in on the stdin stream / $putdata = fopen(""php\ //input"", ""r""); $fp = fopen(""/tmp/test mp4"", ""w""); / read the data 1 kb at a time and write to the file / while ($data = fread($putdata, 1024)) fwrite($fp, $data); / close the streams / fclose($fp); fclose($putdata); ?> customizing the success message after the upload, a message is displayed to the user to provide a custom message to your users, change the upload success message by setting this property properties { "basicupload success message" "enter a custom html message here" } turning off autodelete by default the recorder will remove the local recording from the computer after a successful upload if you would like the user to manage their own recordings using the screenpal project manager, then you can disable this feature by setting this property properties { "som app upload deleteafter" false } sending the user to a url after a successful upload the screenpal application can open a url by setting this property properties { "som app upload onexit action" "http //yoururl/" } you can also return a url as the text result of the push (or put ) upload in which case you can set the value to gotoplayback which will open that url when setting this property the screenpal application will show a "continue" button to the user after a successful upload and then open this url when they click the "continue" button launching the editor (without first recording) to launch the screenpal video manager without first requiring the user to make a recording, add the property showmanager true to the launch properties for example properties { "showmanager" "true", }