Giter VIP home page Giter VIP logo

cloudconvert-laravel's Introduction

CloudConvert Laravel API


Deprecation warning: I don't have the time to support this package any more please use the official CloudConvert Laravel package instead


A Laravel wrapper for the CloudConvert API. See https://cloudconvert.com for more details.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Installation

Install this package through Composer.

Add this to your composer.json dependencies:

Using Laravel 5.0+

"require": {
   "robbiep/cloudconvert-laravel": "2.*"
}

Using Laravel ~4.2

"require": {
   "robbiep/cloudconvert-laravel": "1.*@dev"
}

Run composer install to download the required files.

Next you need to add the service provider to config/app.php

'providers' => array(
    ...
    RobbieP\CloudConvertLaravel\CloudConvertLaravelServiceProvider::class
)

One more step.

You need to publish the config php artisan vendor:publish

Just enter your API key in config/cloudconvert.php

You can get your free API key by registering at https://cloudconvert.com

Now you can use CloudConvert in your application!

Usage

There's many ways to use CloudConvert. I'll cover a few of them here, for all the converter options I suggest checking out the API docs.

File conversion

# Convert the file to /a/path/to/file.mp4

CloudConvert::file('/a/path/to/file.mov')->to('mp4');
# Convert the file and save it in a different location /a/new/path/to/new.mp4

CloudConvert::file('/a/path/to/biggles.webm')->to('/a/new/path/to/new.mp4');
# It also works with Laravel's file upload

if (Input::hasFile('photo'))
{
    CloudConvert::file( Input::file('photo') )->to('/a/local/path/profile_image.jpg');
}
# Convert the image to kitty.jpg with quality of 70%

CloudConvert::file('kitty.png')->quality(70)->to('jpg');
# Convert a PowerPoint presentation to a set of images, let's say you only want slides 2 to 4
# This will save presentation-2.jpg, presentation-3.jpg and presentation-4.jpg

CloudConvert::file('presentation.ppt')->pageRange(2, 4)->to('jpg');

Dynamic file conversion

# Dynamic PDF creation using DOCX/PPTX templates
# See this blog post for more details: https://cloudconvert.com/blog/dynamic-pdf-creation-using-docx-templates/

$variables = ['name' => 'John Doe', 'address' => 'Wall Street'];
CloudConvert::file('invoice_template.docx')->templating($variables)->to('invoice.pdf');

Converter options

There are many more conversion options. I've put shortcuts like the ones above for the most common. However you can pass through any options you like using the withOptions method, such as:

# Convert the meow.wav to meow.mp3 with a frequecy of 44100 Hz and normalize the audio to +20dB

CloudConvert::file('meow.wav')->withOptions([
    'audio_frequency' => '44100', 
    'audio_normalize' => '+20dB'
])->to('mp3');


# Convert the fido_falls_over.mp4 to fido.gif but you only want 10 seconds of it, starting at 1:02

CloudConvert::file('fido_falls_over.mp4')->withOptions([
    'trim_from' => '62', 
    'trim_to' => '72'
])->to('fido.gif');

# Or the same with using the shortcuts:
CloudConvert::file('fido_falls_over.mp4')->trimFrom(62)->trimTo(72)->to('fido.gif');

Chaining multiple conversions

You can also chain multiple conversions on one process, like this:

# Convert a TrueType font in to all the fonts you need for a cross browser web font pack

CloudConvert::file('claw.ttf')->to('eot', true)->to('otf', true)->to('woff', true)->to('svg');

# Or the same thing with an array
CloudConvert::file('claw.ttf')->to(['eot', 'otf', 'woff', 'svg']);

Remote files

It will also work with converting remote files (just make sure you provide a path to save it to)

# Convert Google's SVG logo hosted on Wikipedia to a png on your server

CloudConvert::file('http://upload.wikimedia.org/wikipedia/commons/a/aa/Logo_Google_2013_Official.svg')
            ->to('images/google.png');

Merging PDFs

At the moment, merging only works with remotely hosted files, however in the future it will work with uploaded files and files from storage

# Merge the PDFs in the array in to a single PDF

CloudConvert::merge([
             'https://cloudconvert.com/assets/d04a9878/testfiles/pdfexample1.pdf',                          
             'https://cloudconvert.com/assets/d04a9878/testfiles/pdfexample2.pdf'
            ])
            ->to('merged.pdf');

Website screenshot

CloudConvert will also take a screenshot of a website and convert it to an image or pdf for you:

# Take a screenshot with the default options: 1024px with with full height of webpage

CloudConvert::website('www.nyan.cat')->to('screenshots/nyan.jpg');
# You can also specify the width and the height as converter options

CloudConvert::website('www.nyan.cat')
            ->withOptions([
                 'screen_width' => 1024,
                 'screen_height' => 700
            ])->to('screenshots/nyan.png');

Converting to and from external storage options

At the moment CloudConvert let you use FTP or Amazon S3 as storage options. However it looks like in the future they will add Google Drive and Dropbox to the API

**Please note: ** To use these storage options you will need to provide the configuration in the config/cloudconvert.php

# Lets say you have a PDF and you want to convert it to an ePub file and 
# store it on your Amazon S3 bucket (defined in your config). It's this simple:

CloudConvert::file('/a/local/path/garfield.pdf')->to(CloudConvert::S3('Garfield_converted.epub'));
# You can also override the default options by providing them as an array as the second argument

CloudConvert::file('/a/local/path/garfield.pdf')
            ->to(CloudConvert::S3('Garfield_converted.epub', [
                'bucket'  => 'a-different-bucket',
                'acl'     => 'public-read',
                'region'  => 'us-east-1'
            ]));
# Now you want to convert the file on your S3 to a txt file and store it on a server via FTP

CloudConvert::file(CloudConvert::S3('Garfield_converted.epub'))
            ->to(CloudConvert::FTP('path/to/garfield.txt'));

It's that simple. The storage options CloudConvert::S3($path) and CloudConvert::FTP($path) can be used for both input files and output files.

Non-blocking conversion using a callback URL

When the conversion might take a long time you could use:

# Script: sendConversion
CloudConvert::file('/a/path/to/file.mov')
            ->callback('http://myserver.com/save_file.php')
            ->convert('mp4');
            

# Script: saveFile
CloudConvert::useProcess($_REQUEST['url'])
            ->save('/path/converted.mp4');

Non-blocking conversion using a queue

To use queues you will need have set-up either beanstalk or iron in your config/queue.php

# The queue will check every second if the conversion has finished. 
# It times out after 120 seconds (configurable).

CloudConvert::file('/a/path/to/file.mov')->queue('to', '/a/path/to/file.mp4')

Conversion types

You can view the conversion types using the conversionTypes() method. It always returns Illuminate\Support\Collection.

# To get all possible types

$types = CloudConvert::conversionTypes();
# To get all possible types in a specific group

$types = CloudConvert::conversionTypes('video');
# To get all possible output formats if you know the input format

$types = CloudConvert::input('pdf')->conversionTypes();
# Same if you know the output format and want to see what can be inputted

$types = CloudConvert::output('jpg')->conversionTypes();

Processes status

You may want to list all your processes, running, finished and failed. It always returns a Illuminate\Support\Collection.

# To get all possible types
$processes = CloudConvert::processes();

# To delete a process by ID
CloudConvert::deleteProcess($process_id);

Artisan commands

If you want to do quick conversions or calls to the API from your console, you can use the following commands:

Convert a file

# Options: --opions, --background, --storage, --path
php artisan cloudconvert:convert video.mov mp4
php artisan cloudconvert:convert /path/to/video.mov converted.mp4 --storage='s3'

Website screenshot

# Options: --opions, --storage, --path
php artisan cloudconvert:website www.laravel.com jpg

Processes list

# Options: --delete (used with process_id)
# Argument: process_id (optional) - will show the status of that process
php artisan cloudconvert:processes <process_id>

Conversion types

# Options: --input, --output 
# (both optional - however if you included both you will see all the 
# possible converter options for those types, not just the default ones)
php artisan cloudconvert:types
php artisan cloudconvert:types --input='nice.pdf'
php artisan cloudconvert:types --input='doc' --output='jpg'

Using this package without Laravel

You still need to use composer. Type composer require robbiep/cloudconvert-laravel to download the files, then you can use the package like this:

require_once('vendor/autoload.php');

$cloudConvert = new RobbieP\CloudConvertLaravel\CloudConvert(['api_key' => 'API_KEY_HERE']);

$cloudConvert->file('randomuser.jpg')->to('png');

Todo

  • Release
  • Write some more tests
  • Enable merging of multiple files
  • Enable multiple conversions using one process
  • Refactor the commands
  • Added support for Guzzle ~6.0
  • Readme file is getting long, convert to wiki

Contributing

  1. Fork it
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Credits

Thanks to Lunaweb Ltd. for their API. Go check it out.

Resources

cloudconvert-laravel's People

Contributors

cesar-interacpedia avatar denissc avatar edbentinck avatar reinierkors avatar robbiepaul avatar scrutinizer-auto-fixer avatar slaughter550 avatar vinicius73 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudconvert-laravel's Issues

encoding

Hello!
How to set the encoding?
I use:
$variables = ['template' => 'шаблон_1 kjf'];
CloudConvert::file(public_path().'/files/otch.docx')->templating($variables)->to('pdf');
and get http://clip2net.com/s/3AhDTAc
I tried "mb_convert_encoding", "iconv" but this not helped me.

Installing the package in Laravel 5.1.6 not possible

CASE 1

I'm running Laravel 5.1.6. I follow the install instructions for Laravel 5+ from the GitHub project. After the "robbiep/cloudconvert-laravel": "2.*" dependency is added to composer.json, I run composer update and I get the following error: http://i.imgur.com/zhU3WXU.jpg.

Basically, it claims that the BroadcastServiceProvider is missing, which is actually correct. The provider files are gone after your package is required and tried to be installed.

The BroadcastServiceProvider is a part of upgrate to Laravel 5.1: http://laravel.com/docs/5.1/upgrade#upgrade-5.1.0.

CASE 2

When I try composer install instead, the process is successful, but the CloudConvertLaravelServiceProvider is not created, file of this name does not exist in the project. Then, running php artisan vendor:publish throws this: Class ''RobbieP\CloudConvertLaravel\CloudConvertLaravelServiceProvider'' not found.

Not really sure what is going on. Maybe the documentation on GitHub is not up to date. Maybe I'm doing something incorrectly. In any case, would be nice to get an answer or suggestions. Thanks!

Getting the video thumbnail

Hey,

Thanks for putting this repo together, saved me a ton of time getting the integration with cloud convert working.

Is it possible to also push the video thumbnail up to s3 with a converted video?

I'm converting an mp4 to webm and have seen in the cloud convert docs you can get the thumbnail, I assume using the withOptions method but not sure how I would then push it up to s3 with the video.

Cheers

Issues with density (Laravel 4.2)

Hey, i have some issues when I'm converting my files. The Image-Files are resizing correctly, but the density won't change to 72.

Here is my code.
CloudConvert::file('upload/'.$filename)->withOptions([ 'resize' => $newWidth.'x'.$newHeight, 'density' => '72' ])->to('files/img/'.$fn.'.jpg');

I'm using Laravel 4.2

video thumbnail not generated with command

Hi,

I am trying to create a thumbnail. It works perfectly fine until I add command(), then video is created but folder and image is not created. Do you know how to resolve this issue? Maybe I am doing something wrong, or it is expected behaviour?

Here is my code:

$width = 1280;
$height = 720;
$basename = rand ( 1 , 10000 );

$cloudConvert = CloudConvert::file($file)
                      ->command('-i {INPUTFILE} -filter:v "scale=iw*min('.$width.'/iw\,'.$height.'/ih):ih*min('.$width.'/iw\,'.$height.'/ih), pad='.$width.':'.$height.':('.$width.'-iw*min('.$width.'/iw\,'.$height.'/ih))/2:('.$height.'-ih*min('.$width.'/iw\,'.$height.'/ih))/2" {OUTPUTFILE}')
                      ->withOptions([
                           'thumbnail_count' => '1',
                           'thumbnail_size' => '640x480',
                           'thumbnail_format' => 'png' ])
                      ->callback('https://url.com')
                      ->convert(CloudConvert::s3($basename.'.mp4'));

Any help would be highly appreciated. Thanks

convert PDF and store it on database

Hi I came here across a long search after my requests.
I am using Laravel 5.2

What I am looking for is.
I have one PDF file witch is 50 page.
I need to convert all to two types of images
type one
skip the first image, and start from the second
and combined it with the third, and so on combing 4-5 and 6-7, 8-9 ....
then store them into my database.

type two just convert the PDF to images and store it in my database.

Can this package help me doing so??

Regards

How can i get the Process ID directly

Hello,

Right now i would like to run a conversion command and return the process id to store it in the database, to compare it in the callback to get the download url for the process in case i am running more than one conversion.

Regards,

Can't pass converter options, results in a Guzzle exception

When passing converter options as an array in the following way, Guzzle throws an exception.

$instance = CloudConvert::newInstance()
            ->file($from)
            ->withOptions($options)
            ->callback($callbackUrl)
            ->convert($to);

The exception is:

Invalid resource type: array

And it's occurring in at GuzzleHttp\Psr7\stream_for(array('resize' => '4000')) in MultipartStream.php line 87

Could it be related to this? guzzle/guzzle#1079

Can you confirm that passing options as an array is still supported?

How i will set video resolution of new video output file

Hi guys,
i want to convert video file .mov to mp4 but i don't know how i will set the resolution and buffer size for output file.
Thanks
CloudConvert::file('/public/uploads/gdtbgds125846.mov')->to('/public/convert/gdtbgds125846.mp4');

if using Laravel

I tried to convert any videos from users upload to mp4.
1.) Is that mp4 always take care the best conversion bit rate and small size and will that video support all browsers like safari, IE, Chrome, Firefox, Opera, etc...

in my code
CloudConvert::file($uploadedFile->getRealPath())->quality(70)->to(CloudConvert::S3('users/videos/'.$timestamp.".mp4"));

Error I got
Non-static method RobbieP\CloudConvertLaravel\CloudConvert::file() should not be called statically

Singleton prevents multiple conversions.

I have noticed that inside your service provider you run

$this->app['cloudconvert'] = $this->app->share(function($app)
{
    return new CloudConvert(config('cloudconvert'));
});

which means that each time I call a method via the facade the same instance of RobbieP\CloudConvertLaravel\CloudConvert is given back.

On line 308 of CloudConvert.php you check to see if the resource is empty before setting it and if not you don't set the resource again. This means that you can only ever upload and convert one file. If you attempt to upload multiple files, the first file will be re-uploaded and converted multiple times.

Creating Pictures Thumbnails

Hello,

Right now, I am using this package to convert PDF to JPGs, and it is doing a wonderful job.

My Question is: Is there a option to create Tumbs/Thumbnails from the pictures as well?, so the callback for ex. would return the normal image, and its thumbnail.

Note: I need this function as i am creating flipping book from the returned images, and i want the thumbnails for the TOC.

Regards,
Amir Amin

Class 'App\Http\Controllers\CloudConvert' not found

I found your instructions great, got it installed, but came up with this error.

It took me a day or so trying to figure it out before consulting the gurus on IRC. I'm quite new to Laravel, so it didn't occur to me that you need to add the class to your controller before you can use it (now it seems obvious).

For anyone else trying to solve this, you need to add the following to the top of your page:
use RobbieP\CloudConvertLaravel\Facades\CloudConvert;

I'd recommend adding this into your readme just above the part you mention "Now you can use CloudConvert in your application!".

Thanks for your app!

Ability to track the conversion process progress while converting

Hello,

I read the README and did a briefly code inspection and I did not noticed any way to start a conversion process and instantly return the Process instance to be able to further inspect the conversion progress while conversion is in progress. Is this feature currently supported? If not, is there any chance to implement that? :)

Thank you for your time.

Cannot convert file upload...

I'm not having any luck converting an uploaded Powerpoint file to PDF. I'm using L5. The uploaded file doesn't have an extension so CC returns a cannot convert this format error message. I have made several changes to the library code with no luck. Now I'm running in circles...

Any help???

Call to a member function getFormat() on null, after a commit from 20. June 2016

Hi,

We've been having problems with conversionTypes() method. We used it like this:

$types = CloudConvert::input('jpg')->conversionTypes();

and it worked fine. After composer update we get a fatal error. Basically, CloudConvert->getOutputFormat() suddenly fails.

Took us a while to understand what is going on, because for some of the team members the code worked, for others - not. Turned out that some of us had newer version of your package and for those the fatal error occurred.

Anyway, seems like it all comes down to the change, where this line

return isset($this->output) ? $this->getOutput()->getFormat() : $this->output_format;

changed to this one:

return !isset($this->output_format) ? $this->getOutput()->getFormat() : $this->output_format;

It's hard at this point to be more specific, but hopefully it's enough for you to take a look at possible problems.

Cannot save on Amazon S3

Hi, I am trying to convert file from input and save it on S3.

CloudConvert::file($file)->to(CloudConvert::S3('hello.mp4'));

For some reason it treats s3 as an output format and gives me an error:

{"error":"This conversiontype is not supported!","code":400}

Client->request('post', 'https://api.cloudconvert.com/process', array('json' => array('inputformat' => 'mp4', 'outputformat' => 's3', 'apikey' => 'apikey'), 'synchronous' => true))

I am really struggling here, I would appreciate any help. Thanks

Creating video thumbnail without converting

Is it possible to use this wrapper to create a thumbnail from a video that's already stored on S3? I'm looking at the API docs of CloudConvert, and it seems possible to do it using the normal PHP library, but it seems this wrapper expects an output to be given.

How to enable CacheControl while uploading to Amazon S3

Hello,

I have two questions:

  1. How can i enable CacheControl while uploading to Amazon S3? as it saves a lot of money on the long run.

  2. Does CloudConvert have watermark feature ? for example if i want to add a watermark or website name on the converted images.

Best Regards,
Amir Amin

How to get output files after file convert?

the public function 'getOutput()' doesn't return anything. Is there an accessible function that returns an array of strings of the converted file paths. (I'm not saving it on s3 or ftp)

Multiple File Download to specific folder

Hi Team,
Thanks for the excellent plugin. Am trying to convert PDF to JPG where multiple images are converted and received. I just need to know how to save all the files to a specific folder, My code
CloudConvert::file('http://test.com/Test.pdf')->to('jpg');

Also I tried,
CloudConvert::file('http://test.com/Test.pdf')->to('jpg', ['path' => $filePath]);

Everything saves in public folder and unable to route to a specific folder inside my web application. Is it possible to save all files inside specific folder?

accessing the process id

Hey,

I need to access the process ID when I make a request so I can save it to a DB and do some stuff with it when the callback comes back from cloud convert. The only way I can do this is by changing the $process property on the cloud convert class to public then doing this:

    $cloudconvert =  CloudConvert::file($url)->withOptions([
            'thumbnail_count' => '1',
            'thumbnail_size' => '203x113',
            'thumbnail_format' => 'png'
        ])->callback(env('SITE_URL') . '/events/videoConverted')->convert('webm');

        $processId = $cloudconvert->process->id;

The only issue with this is that i've had to override something in your core library which isn't ideal as I would then have to prevent it from updating.

Is there currently a better way to access the ID? If not would it be possible to add this in?

Laravel 5.1 Support

Hi.

I'm trying to install this package to a Laravel 5.1 project. Unfortunately, Composer refuses to install the package.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for robbiep/cloudconvert-laravel 2.* -> satisfiable by robbiep/cloudconvert-laravel[v2.1].
    - Conclusion: remove laravel/framework v5.1.1
    - Conclusion: don't install laravel/framework v5.1.1
    - robbiep/cloudconvert-laravel v2.1 requires illuminate/filesystem 5.0.*@dev -> satisfiable by illuminate/filesystem[v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4].
    - don't install illuminate/filesystem v5.0.0|don't install laravel/framework v5.1.1
    - don't install illuminate/filesystem v5.0.22|don't install laravel/framework v5.1.1
    - don't install illuminate/filesystem v5.0.25|don't install laravel/framework v5.1.1
    - don't install illuminate/filesystem v5.0.26|don't install laravel/framework v5.1.1
    - don't install illuminate/filesystem v5.0.28|don't install laravel/framework v5.1.1
    - don't install illuminate/filesystem v5.0.33|don't install laravel/framework v5.1.1
    - don't install illuminate/filesystem v5.0.4|don't install laravel/framework v5.1.1
    - Installation request for laravel/framework == 5.1.1.0 -> satisfiable by laravel/framework[v5.1.1].

I think it may be as simple as bumping your "illuminate/filesystem": "5.0.*@dev" line in composer.

Thanks!

How to retrieve callback parameters

I am using callback function and I want to notify the user when conversion is finished. How to retrieve the process id which is finished with callback? Will multiple conversions will work at the same time?
Thank you in advance.

Authentication issues

Hi,

I've installed this components using composer on Laravel 5 but I can't get it to work.
All I get for every request is "No API key provided." even though I've set them in config/cloudconvert.php.

I've tried re-installing multiple times but always end up with the same results.

Any ideas?

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

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?

Queue and saving to S3

Hi, cheers for making this!

I'm having a problem getting queues to work with Amazon S3. When I do this:

CloudConvert::file(asset(Storage::url($path)))->queue('to', CloudConvert::S3($thumb_full_name));

I get back this error: {"error":"This conversiontype is not supported! (pdf to AKIAJTZQLLWBR2GD72OQ)","code":400}

If I change the file name from the variable to test.jpg I still get that error. Should I be using the queue method in a different way to get it to work?

Cheers!

Symfony UploadedFile

Thank you for the package.

How can I convert file using Symfony Uploaded file as an input and saving it somewhere else?

app('cloudconvert')->file($uploadedFile)->to('pdf', true)->save(storage_path())

Client error: GET https://host123d1qp.cloudconvert.com/download/~qPUuwEqiICsPI4AKiI1B-iUBtXY resulted in a 400 Bad Request response:
{"error":"This process does not have any output files.","code":400}

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

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.

Conversion fails when using Laravel's file upload

Hi,

When attempting to convert a file by passing the file upload object Symfony\Component\HttpFoundation\File\UploadedFile, the conversion fails with bad request.

I did some digging into it, and it seems there are multiple issues. Firstly, in the ConvertLocalFile class if its an instance of UploadedFile you run $this->setFile($file->getFilename());. This only gives the filename and not the path on disk. I believe it should be set to $this->setFile($file->getPathname());.

This still doesn't solve the issue of setting the file extension as getPathname returns a temporary path which doesn't contain the extension. I tried adding $this->setFormat($file->getClientOriginalExtension()); under where you set the filename and this seemed to solve the first issue.

However, later is still fails with 400 "Bad Request". If I visit the process url it gives back a json object including the error "File not found (Upload failed)".

I am unsure how to solve this.

The changes I made are:

function __construct($file, $converteroptions = null)
    {
        parent::__construct($file, $converteroptions);
        $this->setMethod(CloudConvert::INPUT_UPLOAD);
        $this->setFilesystem();
        if($file instanceof UploadedFile) {
            $this->setFile($file->getFilename());
            $this->setFormat($file->getClientOriginalExtension());
        }
    }

Moving to S3 with Callback API

Hey,

I've having some trouble getting the library working when trying to add the s3 options to the output array along with the a callback url.

This way throws an error saying process already started but cloud convert still uploads the files to S3 and makes the callback to the URL (So it does actually work but crashes my code with the errror).

 $cloudconvert = CloudConvert::file($url)->withOptions([
            'thumbnail_count' => '1',
            'thumbnail_size' => '203x113',
            'thumbnail_format' => 'png'
        ])->callback('http://requestb.in/1n48f3k1')->to(CloudConvert::S3($output) );

The only way I can get the process to start without throwing an error is:

 $cloudconvert = CloudConvert::file($url)->withOptions([
            'thumbnail_count' => '1',
            'thumbnail_size' => '203x113',
            'thumbnail_format' => 'png'
        ])->callback('callback_url')->convert('webm')

I've tried to then push to s3 on the callback url using the useProcess method but keep getting an output format does not match format provided error. I think this may be to do with the output file actually being 2 files the png thumbnail and the webm file. If I view the details url it shows the two files and a .zip file too. When using the "to" method to push to s3 when starting the process it works fine I just can't get it to work in the callback. Or get the initial process to accept the S3 options without erroring.

Does this make sense?

Retrieve callback reponse to client-side

Hi, I understand this is not completely related to this API but I would like to ask for your help. Is there any way to pass parameters from callback function to client size and notify the user when conversion is completed?

I would really appreciate any help.
Thanks.

Get file information

Hello,

There is a method to extract file metadata from PDF, image, video and audio files, is it included in this package? and how to use it.

For more details about it, kindly check the following link:
https://cloudconvert.com/api/info

Regards,

"Could not be converted"

Hi, thanks for this repo...really helpful. I implemented it and it works great for images, and pushes them to s3 just fine. But when I try any vide, I get "Could not be converted". Anyone had this issue before and any ideas what caused it?

/** store function in the controller **/
public function store()
{
    if (Input::hasFile('photo')){
        CloudConvert::file(Input::file('photo'))->convert(CloudConvert::S3('TestVideo.webm'));
        return redirect('/upload');
    }
}

/** upload form in view **/
{!! Form::open(['action' => 'UploadController@store', 'method'=>'POST', 'files' => true]) !!}
    <div class="form-group">
          {!! Form::label("photo", "Upload Image:") !!}
          {!! Form::file("photo", null, ['class'=>'form-control']) !!}
     </div>
     <div class="form-group">
            {!! Form::submit("Create", ['class'=>'btn btn-success pull-right']) !!}
     </div>
{!! Form::close() !!}

This works well for images, both saving to a local folder and to s3, but I get this "Count not be converted" message for videos. My test video is 1minute in length.

Thanks in advance for any help.

Cannot save to S3 as part of a callback.

I have been trying in vein to say a file to S3 as part of a callback.

The code I have tried is:

CloudConvert::useProcess($processUrl)
    ->save(CloudConvert::S3('some/aws/key.pdf'));

No errors are thrown. It simply doesn't upload the file. Is this something which is supported?

As a temporary workaround I use the following code:

$cloudConvert = CloudConvert::useProcess($processUrl);

$file = $cloudConvert->getProcess()->download();

Storage::put('some/aws/key.pdf', $file);

Thanks, Ian

File does not get converted (?)

I'm trying to convert .flv to .mp4.

When uploading:
CloudConvert::file($file)->to(CloudConvert::S3($id.'.mp4'));

Everything seems to work fine, but when I download and open the generated file it seems to be in flv format still 😕.

When manually converting it on the site itself, I get the correct video in flv format.

Any guidance would be appreciated.

utf8_encode template converting

When you try to convert a docx to a pdf using the templating method, there is a problem with accents.

I found the line that cause the problem :

File : \RobbieP\CloudConvertLaravel\HttpClientAdapter\Guzzle6Adapter
Method : castContents
line: 188

Simply by removing the utf8_encode, it works

I'm wondering why it need to be encoded in uft8, and if by removing the part of code it will not create an other bug.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.