robbiepaul / cloudconvert-laravel

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

Non-blocking conversion using a callback URL - file not downloaded #28

Closed rgozdzialski closed 8 years ago

rgozdzialski commented 8 years ago

I'm following the implementation provided here. To test it, I call /convert URL on my server. The robots.txt file is being converted correctly, but is not stored back on the server as PDF using the callback function.

The code:

/* /convert */
public function convert() {
      CloudConvert::file(public_path('robots.txt'))
            ->callback('http://my-public-server.com/convert-save')
            ->convert('pdf');
}

then

/* /convert-save callback */
public function convertSave() {
        CloudConvert::useProcess(Request::input('url'))
            ->save(public_path('robots.pdf'));
}

Both /convert and /convert-save are public, reachable URLs.

Anything wrong with my implementation? Anything I'm missing?

robbiepaul commented 8 years ago

I just tested it, it works.

Make sure /convert-save is a POST route and you have CSRF disabled for that route, see the Laravel docs: https://laravel.com/docs/master/routing#csrf-excluding-uris

rgozdzialski commented 8 years ago

I did both of the things and retested - no luck. What confuses me a bit is that you suggest to change the callback route to POST, while the API docs specifies they will do a GET to the callback URL.

Anyway, it works for you, so it has to be something environment specific. I would say, if you don't have more ideas, let's close the issue.

Btw, I'm using Laravel 5.2.34

robbiepaul commented 8 years ago

You're right it is a GET route, I was looking at the hooks section of the API. The callback still works for me though.

Here's my code:

Route::get('/callback', function(){
    CloudConvert::useProcess($_REQUEST['url'])
                ->save(public_path('robots.pdf'));
});