Skip to content

Commit

Permalink
Handle image_source with ConvertBase64ToFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
PetriAsi committed Jul 7, 2021
1 parent f53cabe commit 168d7f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
39 changes: 0 additions & 39 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,22 +459,6 @@ public function store(ImageUploadRequest $request)
$asset->rtd_location_id = $request->get('rtd_location_id', null);
$asset->location_id = $request->get('rtd_location_id', null);

if ($request->has('image_source') && $request->input('image_source') != "") {
$saved_image_path = Helper::processUploadedImage(
$request->input('image_source'), 'uploads/assets/'
);

if (!$saved_image_path) {
return response()->json(Helper::formatStandardApiResponse(
'error',
null,
trans('admin/hardware/message.create.error')
), 200);
}

$asset->image = $saved_image_path;
}

$asset = $request->handleImages($asset);

// Update custom fields in the database.
Expand Down Expand Up @@ -561,31 +545,8 @@ public function update(ImageUploadRequest $request, $id)
($request->filled('company_id')) ?
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : '';

($request->filled('rtd_location_id')) ?
$asset->location_id = $request->get('rtd_location_id') : null;


if ($request->filled('image_source')) {
if ($request->input('image_source') == "") {
($request->filled('rtd_location_id')) ?
$asset->location_id = $request->get('rtd_location_id') : null;
$asset->image = null;
} else {
$saved_image_path = Helper::processUploadedImage(
$request->input('image_source'), 'uploads/assets/'
);

if (!$saved_image_path) {
return response()->json(Helper::formatStandardApiResponse(
'error',
null,
trans('admin/hardware/message.update.error')
), 200);
}

$asset->image = $saved_image_path;
}
}

$asset = $request->handleImages($asset);

Expand Down
5 changes: 5 additions & 0 deletions app/Http/Requests/ImageUploadRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ public function response(array $errors)
*/
protected function base64FileKeys(): array
{
/**
* image_source is here just legacy reasons. Api\AssetController
* had it once to allow encoded image uploads.
*/
return [
'image' => 'auto',
'image_source' => 'auto'
];
}

Expand Down

0 comments on commit 168d7f7

Please sign in to comment.