Closed bewitchingme closed 10 months ago
Can you provide a code snippet?
$exportTask = (new Task('export/s3', $exportTaskIdentifier))
->set('input', [$convertTaskIdentifier])
->set('bucket', env('CLOUDCONVERT_S3_BUCKET'))
->set('key', "{$storageUuid}/page_%d.jpg")
->set('region', env('CLOUDCONVERT_S3_REGION'))
->set('access_key_id', env('CLOUDCONVERT_S3_ACCESS_KEY'))
->set('secret_access_key', env('CLOUDCONVERT_S3_SECRET_ACCESS_KEY'));
$job = (new Job())
->setTag($jobTag)
->addTask(
(new Task('import/url', $importTaskIdentifier))
->set('url', 'https://www.africau.edu/images/default/sample.pdf')
->set('filename', 'sampleunsecuredpdf.pdf')
)
->addTask(
(new Task('convert', $convertTaskIdentifier))
->set('input_format', 'pdf')
->set('output_format', 'jpg')
->set('engine', 'mupdf')
->set('input', [$importTaskIdentifier])
->set('pixel_density', 300)
)
->addTask($exportTask);
$cloudConvert->jobs()->create($job);
$cloudConvert->jobs()->wait($job);
print_r($exportTask->getResult());
I would expect there to be something reported for the result. Tried looking at $job->getExportUrls() as well and it always returns an empty array.
It should be noted that the above does indeed create the assets in S3, I just have no way of knowing how many files were written unless I get a list of objects in that bucket myself.
You need to update your job object with the wait result:
$job = $cloudConvert->jobs()->wait($job);
Result:
> $j = $ccc->convertPdfToImages('');
Array
(
[result_urls] => Array
(
)
[result_task] =>
)
After adding:
$cloudConvert->jobs()->create($job);
$job = $cloudConvert->jobs()->wait($job);
print_r([
'result_urls' => $job->getExportUrls(),
'result_task' => $exportTask->getResult(),
]);
Doing this in the sandbox if that makes any difference.
getExportUrls()
will not work here because you are using export/s3
. It only works for export/url
.
You would need something like:
$job = $cloudConvert->jobs()->wait($job);
$exportResult = $job->getTasks()
->status(Task::STATUS_FINISHED)
->operation('export/s3')[0]
->getResult();
print_r($exportResult);
Ah, excellent! My IDE suggests that status
and operation
are deprecated, is there a more modern means of doing this?
Found the methods prefixed by where
, thanks for your assistance and illumination!
Once my job is finished, I was hoping to be able to see the list of files written by the export task and when attempting to see some result with the
getResult()
method, my experience is that this returned no data at all. How can I know how many files were written to my S3 bucket in the case of converting a PDF to images?