Upload via Flash
Hello,
Is there anything that would allow me to upload to vzaar using flash? So that my users could have a progress bar on the upload?
I was watching a discussion on this subject (http://help.vzaar.com/discussions/api/44-uploading-via-flash), but then I think it become private.
I'm currently using the PHP API. Before the above topic became private, I read that you were soon to be releasing the Ruby API with this capability. I am quite accomplished in PHP, and would most likely be able to port the Ruby functionality over to the PHP API.
Thank you in advance.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by ianjsnead on 08 Feb, 2010 07:00 PM
I have copied this from the conversation you were following. Let me know if this helps.
Hi,
first please get familiar with our API Upload manual (unless you already did): http://developer.vzaar.com/docs/version_1.0/uploading/overview .
As you can see there are 3 major steps when uploading a video via the API.
First step is to acquire a signature, which will allow you to upload videos to our S3 bucket. To get it you need to make a GET request to /videos/signature (http://developer.vzaar.com/docs/version_1.0/uploading/sign). One way of doing it with SWFUpload is to create an action on your server which is able to get a signature from vzaar and then in your SWFUpload upload_start_handler you make an XHR to the action. At this point you will be able to set post_params for your SWFUpload instance to make it capable of uploading to our S3 bucket.
Once you have set the post_params your SWFUpload instance starts uploading video to S3 (http://developer.vzaar.com/docs/version_1.0/uploading/upload).
When the upload is finished it's time to let vzaar know about the newly uploaded video. You do so by POSTing to /videos (http://developer.vzaar.com/docs/version_1.0/uploading/upload). A good place to implement this in SWFUpload is the upload_success_handler. And again, you create an action on your server which makes the POST to vzaar's /videos and in the upload_success_handler you make an XHR with appriopriate params.
So this is an overview of how you could implement the API upload using the SWFUpload. I omitted some details in order to make my answer readable, so please do not hesitate to ask in-depth questions when they arise.
3 Posted by Innersection on 10 Feb, 2010 10:52 AM
This helped a lot. Though I've got another problem that I can't solve. So when I need to get the upload signature (http://developer.vzaar.com/docs/version_1.0/uploading/sign) if I send flash_request in the parameters, it says I should be able to use a flash uploader. BUT it doesn't say what exactly changes with the signature/policy. On the Amazon S3 help (http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?HT...), it says that the following addition needs to be made to the Policy:
['starts-with', '$Filename', '']
Is this what is added when I send the flash_request parameter?
Edit: Just realised that you are adding the above thing to the policy... Though you're sending 3 'starts-with':
{ 'expiration': '2010-02-10T13:28:50.000Z', 'conditions': [ {'bucket': 'vz1'}, ['starts-with', '$key', 'vzaar/vz1/717/source/vz1717a671b1224afdb988504ffefd9919/'], {'acl': 'private'}, ['eq', '$success_action_status', '201'] , ['starts-with', '$success_action_redirect', ''], ['starts-with', '$Content-Type', ''], ['starts-with', '$Filename', ''] ]}
Without the Flash....
{ 'expiration': '2010-02-10T13:29:28.000Z', 'conditions': [ {'bucket': 'vz1'}, ['starts-with', '$key', 'vzaar/vzf/184/source/vzf18403be512b442681b2f32b04be39cd/'], {'acl': 'private'}, ['eq', '$success_action_status', '201'] , ['starts-with', '$success_action_redirect', ''] ]}
Could the multiple starts-with be the problem?
End Edit
It also suggests that the crossdomain.xml should have a secure="false" attribute. Would this make a massive difference to the error?
I'm currently getting a security error from the Flash, though I know that the Flash is finding the crossdomain.xml at https://vz1.s3.amazonaws.com/crossdomain.xml.
Has anyone ever got it working when directly uploading to the S3 from the Flash?
If I try to upload over a non-secure (http) connection, I get a 403 error.
Any ideas?
Thanks!
4 Posted by Innersection on 10 Feb, 2010 11:48 AM
Ok, ignore my edit. After more research, the multiple starts-with won't be the problem. And I won't need to use the flash_request parameter, as my Flash it posting the file as $file not $Filename.
I'm still totally stumped though.
Is there a way I could talk this through with a tech on the phone?
Thanks.
Support Staff 5 Posted by ianjsnead on 10 Feb, 2010 12:54 PM
Can you please let me have your number and I will arrange for a tech to call you.
Thanks,
Ian
6 Posted by Innersection on 10 Feb, 2010 12:57 PM
My number is Edited out.
Thank you.
Chris Neal
Support Staff 7 Posted by ianjsnead on 10 Feb, 2010 01:01 PM
Thanks. In the mean time this was the last post on the original thread you were watching:
____________ Ok I got it working after looking at Your guys JS files :)
I made changes to Vzaar.php:
1.public static function getUploadSignature($redirectUrl=null, $flash=null) {
2. if($flash!=null) {
now it's working fine.. could be nice to write somewhere in docs that You need to add ?flash_request=true when upload from flash.
8 Posted by Innersection on 10 Feb, 2010 01:06 PM
I've tried adding that... And unfortunately that doesn't seem to fix the issue.
Thanks for your help Ian, I look forward to the tech calling me.
Did you make a note of my number? I'd like to make this topic public again, so others in the same situation can follow its progress.
Support Staff 9 Posted by ianjsnead on 10 Feb, 2010 01:09 PM
I have made this public and Mariusz is going to be calling you in 15 mins.
10 Posted by Innersection on 10 Feb, 2010 06:29 PM
Ok, for anyone that cares...
I'm using SWF Upload 2.2.0, with the PHP API. I've tweaked the getUploadSignature function to:
$url.="api/videos/signature"; $url.="?".'flash_request=true'; if($redirectUrl!=null) {
$_url.="&".'success_action_redirect='.$redirectUrl; }
So just added the flash_request=true to the params. This will send the extra thing back in the policy. FYI, the policy is base64_encoded.
Then in SWFUpload I'm using the post_params object to send:
post_params : {
"content-type" : "binary/octet-stream", "acl" : "<?php echo $signature['acl']; ?>", "bucket" : "<?php echo $signature['bucket'];?>", "policy" : "<?php echo $signature['policy']; ?>", "AWSAccessKeyId" : "<?php echo $signature['accesskeyid']; ?>", "signature" : "<?php echo $signature['signature']; ?>", "success_action_status" : "201", "key" : "<?php echo $signature['key']; ?>" },
$signature is the vzaar-api key, returned from $signature = Vzaar::getUploadSignature();
I found that the content-type was the bit holding me back. I previously had "application/octet-stream", though this was causing me to get a 403 error on uploading to the http S3. Changing it to binary/octet-stream has solved it.
I hope this helps someone, as I've spent 3 days going round the houses on this.
Thanks to "Mariusz" from Vzaar tech support, and Ian!!
Support Staff 11 Posted by ianjsnead on 12 Feb, 2010 12:54 PM
Hi Chris,
I wanted to see how you were getting on. If you like you can contact me directly: ian at vzaar dot com
Cheers,
Ian
ianjsnead resolved this discussion on 16 Feb, 2010 08:36 AM.