screen
screen copied to clipboard
Help - Integration With Laravel Job
I'm looking to integrate this with a laravel install that requires a login, but any time I try to take a snapshot of a laravel-generated URL, the image won't save out (but the job does save out). For example, I have a dispatched event handling the request:
public function handle(){
$fileName = $this->component->entity_id."_".date("Y-m-d").'.jpg';
//take screenshot
$fileLocation = storage_path()."/app/tmp/".$fileName;
$screenCapture = new Capture(route("admin.components.preview", $this->component->id));
//$screenCapture = new Capture("http://google.com"); // this works!
$screenCapture->jobs->setLocation(storage_path().'/app/weber-screens/');
$screenCapture->setTimeout(5000);
$screenCapture->setWidth(1400);
if($screenCapture->save($fileLocation)){ //returns false unless using Google's URL
//upload screenshot to s3
$s3 = \Storage::disk('s3');
$dir = "/screens/";
$filePath = $dir. $fileName;
$thumbPath = $dir."/thumbs" . $fileName;
$s3->put($filePath, file_get_contents($screenCapture->getImageLocation()), 'public');
//delete temp file
unlink ( $fileLocation );
return true;
}
}
Using the laravel route, I don't get any file saved out (screenCapture->save() returns false). But if I go to the job saved out, copy the command, and run it manually in the CLI it saves out correctly.
Hi, seems your route cannot be opened from cli
you must give a valid address which is reachable over internet
your "route" maybe is producing unreachable URL when you run it from the command line
the capture script spawns a new process and it does not know about laravel
try to see what your route outputs to other CLI programs
for example try
exec("curl ".route("admin.components.preview", $this->component->id))." ")
and see if there is any output
Thanks for replying.
The generated job JS file has the command you are referring to, right? Because when I copy and paste that into the CLI, it works fine.
On Wed, Apr 19, 2017 at 3:14 AM, Peter Ivanov [email protected] wrote:
Hi, seems your route cannot be opened from cli
you must give a valid address which is reachable over internet
your "route" maybe is producing unreachable URL when you run it from the command line
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/microweber/screen/issues/88#issuecomment-295201989, or mute the thread https://github.com/notifications/unsubscribe-auth/AFMEiTGoNHxtkYfettWN6iMs7kxnkVxVks5rxd5wgaJpZM4NBCe7 .
hi, another guess maybe check if the files in the bin
folder are executable
maybe make chmod +x
on the files in the bin folder and try again
You must set the url of your application in order to use the route in laravel jobs.
Find the setting in app config and replace the appropriate url