Code Duplication    Length = 4-5 lines in 2 locations

code/Controller/AssetAdmin.php 2 locations

@@ 327-331 (lines=5) @@
324
        $data['Parent'] = $parentRecord;
325
326
        $tmpFile = $request->postVar('Upload');
327
        if(!$upload->validate($tmpFile)) {
328
            $result = ['error' => $upload->getErrors()];
329
            return (new HTTPResponse(json_encode($result), 400))
330
                ->addHeader('Content-Type', 'application/json');
331
        }
332
333
        // TODO Allow batch uploads
334
        $fileClass = File::get_class_for_file_extension(File::get_file_extension($tmpFile['name']));
@@ 646-649 (lines=4) @@
643
                ->addHeader('Content-Type', 'application/json');
644
        }
645
646
        if (!$record->canEdit() || ($doPublish && !$record->canPublish())) {
647
            return (new HTTPResponse(json_encode(['status' => 'error']), 401))
648
                ->addHeader('Content-Type', 'application/json');
649
        }
650
651
        $form->saveInto($record);
652
        $record->write();