robbiepaul / cloudconvert-laravel

A Laravel wrapper for the CloudConvert API
177 stars 34 forks source link

Non-blocking conversion using a callback URL not saving on S3 #21

Closed bachras closed 8 years ago

bachras commented 8 years ago

I am trying to use non-blocking conversion, but it does not seem to work for me. Could you help me? Here is the code I am using:

public function postSendPost() { 

 $files = $request->file("file");

foreach($files as $file){

 CloudConvert::file($file)->callback('https://mywebsite.com/feed/completeVideoConversion')
                                      ->convert('mp4');
 }
}
public function getCompleteVideoConversion() {  

$rand = rand ( 1 , 10000 );
CloudConvert::useProcess($_REQUEST['url'])->save(CloudConvert::s3($rand.'.mp4'));
}

I have checked that process is created and I am able to download the file via the download url from cloudconvert server, but is not saving on S3.

Thanks for your help in advance.

robbiepaul commented 8 years ago

@bachras Please check out this closed issue: https://github.com/robbiepaul/cloudconvert-laravel/issues/12

The S3 uploading is handled by CloudConvert, therefore needs to be configured before the conversion process starts. The callback will simply be a notification that the process is complete

bachras commented 8 years ago

Thanks for prompt response. I have read that closed issue and I am a bit confused. As far as I understand callback is not required when file is saved on S3? Is that right? I will try to use this code other day as I already reached my limit on testing. Is it right?

public function postSendPost() { 

 $files = $request->file("file");

foreach($files as $file){
$rand = rand ( 1 , 10000 );
 CloudConvert::file($file)->callback('https://mywebsite.com/feed/completeVideoConversion')
                                      ->convert(CloudConvert::s3($rand.'.mp4'));
 }
}

How I will be notified that file is saved on S3?

Thanks again.

robbiepaul commented 8 years ago

You're right callback is not required for saving to S3.

However if you want to be notified when the process is complete and CloudConvert has uploaded the file to your S3 bucket then include a callback URL. So in your case it would be something like

public function postSendPost() { 
    $files = $request->file("file");
    foreach($files as $file){
        $rand = rand ( 1 , 10000 );
        CloudConvert::file($file)->callback('https://mywebsite.com/feed/completeVideoConversion')
                                 ->convert(CloudConvert::S3($rand.'.mp4'));
    }
}

and in your callback URL

public function getCompleteVideoConversion() {  
    // Any logic you like to let your application know $_REQUEST['url'] process is complete
}
bachras commented 8 years ago

File saving works perfectly fine now, but callback URL is not requested. For testing purposes I am trying to insert entry into database and it is not happening.

Could you advise me on this please? Thanks

robbiepaul commented 8 years ago

Have you got a route set up correctly?

Does a database entry get inserted when you manually visit https://mywebsite.com/feed/completeVideoConversion?url=testing ?

bachras commented 8 years ago

Route is set up correctly as I already tried to visit same URL before via browser and it was inserting properly and getting parameters from URL. Do you know want could be wrong? Did you try youself? Does it work for you?

Thanks

robbiepaul commented 8 years ago

Please run another update and see if it fixes your issue

bachras commented 8 years ago

It is working now. Thank you for your help, I really appreciate that.

robbiepaul commented 8 years ago

No problem, thanks for reporting it