@deladels Well what’s the error you get on Heroku…?
May 26, 2020
4
Level 4
Jobs failing on heroku but work correctly in local environment
I have some jobs set up to upload files to Digital Ocean Spaces in the background. What I noticed is that, the jobs run perfectly and the files are uploaded. But in production, I find out that the jobs are failing.
Any idea what could be going wrong? Or anyone experienced this before?
this is my job's handle method.
public function handle()
{
Storage::disk('DO')->put(
'uploads/business-registration/'.$this->certificateFileName,
file_get_contents(
public_path().'/storage/uploads/business-registration/'.$this->certificateFileName)
);
Storage::delete(public_path().'/storage/uploads/business-registration/'.$this->certificateFileName);
}
this is my file upload service class with a handle function to process the file upload.
public function powerPointFileUpload(Request $request) : string
{
$powerPointFile = $request->file('powerpoint');
$powerPointFilename = $this->filename(
$request->company_name, $powerPointFile
);
$powerPointFile->storeAs(
'uploads/powerpoint', $powerPointFilename, 'public'
);
PowerPointFileUpload::dispatch($powerPointFilename);
return $powerPointFilename;
}
the controller method calling the file upload service
public function store(StoreAgriBusinessInformationRequest $request, FileUploadService $fileUpload)
{
$uploadService = $fileUpload->handle($request);
$registration = AgribusinessInformation::create($request->validated() + [
'user_id' => Auth::user()->id
]);
if (isset($uploadService['certificateFilename'])) {
$registration->update([
'attachments' => $uploadService['certificateFilename']
]);
}
session()->flash('success', 'Agribusiness Information Saved Successfully');
return redirect()->route('personal-information.create');
}
Also, I have the jobs table already migrated and changed the QUEUE_CONNECTION to database on heroku
Please or to participate in this conversation.