Add uploadFinishPhotos API call. #421
This commit is contained in:
parent
ce64a1b64d
commit
334b0f1c99
1 changed files with 85 additions and 7 deletions
|
|
@ -1368,6 +1368,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$jo_extra = $jo->getJOExtra();
|
||||||
|
if ($jo_extra == null)
|
||||||
|
{
|
||||||
// create JOExtra entity
|
// create JOExtra entity
|
||||||
$jo_extra = new JOExtra();
|
$jo_extra = new JOExtra();
|
||||||
|
|
||||||
|
|
@ -1378,6 +1381,14 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
$jo->setJOExtra($jo_extra);
|
$jo->setJOExtra($jo_extra);
|
||||||
|
|
||||||
$this->em->persist($jo_extra);
|
$this->em->persist($jo_extra);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$jo_extra->setBeforeSpeedImageFilename($new_speed_filename);
|
||||||
|
$jo_extra->setBeforeBattImageFilename($new_batt_filename);
|
||||||
|
$jo_extra->setBeforePlateNumImageFilename($new_plate_num_filename);
|
||||||
|
}
|
||||||
|
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1393,6 +1404,73 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
if (isset($data['error']))
|
if (isset($data['error']))
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
|
$dest = $this->upload_dir;
|
||||||
|
|
||||||
|
$speed_img_file = $req->files->get('speedomtr_img');
|
||||||
|
$batt_img_file = $req->files->get('battery_img');
|
||||||
|
$plate_num_img_file = $req->files->get('plate_number_img');
|
||||||
|
|
||||||
|
if ((empty($speed_img_file)) &&
|
||||||
|
(empty($batt_img_file)) &&
|
||||||
|
(empty($plate_num_img_file)))
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'error' => 'No image files received.'
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// save speedometer file
|
||||||
|
$orig_speed_filename = pathinfo($speed_img_file->getClientOriginalName(), PATHINFO_FILENAME);
|
||||||
|
$new_speed_filename = uniqid() . '-'. $orig_speed_filename . '.' . $speed_img_file->guessClientExtension();
|
||||||
|
|
||||||
|
// save battery file
|
||||||
|
$orig_batt_filename = pathinfo($batt_img_file->getClientOriginalName(), PATHINFO_FILENAME);
|
||||||
|
$new_batt_filename = uniqid() . '-' . $orig_batt_filename . '.' . $batt_img_file->guessClientExtension();
|
||||||
|
|
||||||
|
// save plate number file
|
||||||
|
$orig_plate_num_filename = pathinfo($plate_num_img_file->getClientOriginalName(), PATHINFO_FILENAME);
|
||||||
|
$new_plate_num_filename = uniqid() . '-' . $orig_plate_num_filename . '.' . $plate_num_img_file->guessClientExtension();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$speed_img_file->move($dest, $new_speed_filename);
|
||||||
|
$batt_img_file->move($dest, $new_batt_filename);
|
||||||
|
$plate_num_img_file->move($dest, $new_plate_num_filename);
|
||||||
|
}
|
||||||
|
catch (FileException $e)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'error' => 'Error saving image files.'
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$jo_extra = $jo->getJOExtra();
|
||||||
|
if ($jo_extra == null)
|
||||||
|
{
|
||||||
|
// create JOExtra entity
|
||||||
|
$jo_extra = new JOExtra();
|
||||||
|
|
||||||
|
$jo_extra->setAfterSpeedImageFilename($new_speed_filename);
|
||||||
|
$jo_extra->setAfterBattImageFilename($new_batt_filename);
|
||||||
|
$jo_extra->setAfterPlateNumImageFilename($new_plate_num_filename);
|
||||||
|
|
||||||
|
$jo->setJOExtra($jo_extra);
|
||||||
|
|
||||||
|
$this->em->persist($jo_extra);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$jo_extra->setAfterSpeedImageFilename($new_speed_filename);
|
||||||
|
$jo_extra->setAfterBattImageFilename($new_batt_filename);
|
||||||
|
$jo_extra->setAfterPlateNumImageFilename($new_plate_num_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue