Store a newly created Files in storage.

@param FileRequest $request

@return Response
7424
public function upload(Request $request)
    {
        $validation = app(ValidationService::class)->check([
            'location' => ['required'],
        ]);

        if (!$validation['errors']) {
            $file = $request->file('location');
            $fileSaved = app(FileService::class)->saveFile($file, 'public/images', [], true);
            $fileSaved['name'] = CryptoService::encrypt($fileSaved['name']);
            $fileSaved['mime'] = $file->getClientMimeType();
            $fileSaved['size'] = $file->getClientSize();
            $response = app(CmsResponseService::class)->apiResponse('success', $fileSaved);
        } else {
            $response = app(CmsResponseService::class)->apiErrorResponse($validation['errors'], $validation['inputs']);
        }

        return $response;
    }
721604
public function saveAction(Request $request)
    {
        $all = $request->get('all');
        $action = $request->get('action');
        $tempId = $request->get('temp_id');

        $metaData = $request->get('meta', null);
        if ($metaData) {
            $metaData = json_decode($metaData, true);
        }

        $tempHandler = $this->get('phlexible_media_manager.upload.temp_handler');

        if ($all) {
            $tempHandler->handleAll($action);
        } else {
            $file = $tempHandler->handle($action, $tempId);

            if ($file && $metaData) {
                $this->saveMeta($file, $metaData);
            }
        }

        return new ResultResponse(true, ($all ? 'All' : 'File').' saved with action '.$action);
    }
1122001
public function store(FormRequest $request)
    {
        $data = $request->all();
        $model = $this->repository->create($data);

        if (request()->wantsJson()) {
            return response()->json([
                'error' => $model ? false : true,
                'model' => $model->load('children'),
            ], 200);
        }

        return $this->redirect($request, $model);
    }
977566
public function store(UploadFileRequest $request)
    {
        $file = $request->file('file');

        $fileName  = uniqid('upload') . '.' . $file->extension();
        $storeDir  = rtrim(config('cms-upload-module.upload.path'), '/');
        $storePath = $storeDir . '/' . $fileName;

        $mimeType = $file->getMimeType();

        if ( ! $this->fileChecker->check($file->getClientOriginalName(), $mimeType)) {
            return response()->json([
                'success' => false,
                'error'   => cms_trans('upload.error.disallowed-type'),
            ]);
        }

        // Apply custom request-specified validation
        $rules     = $request->getNormalizedValidationRules();
        $validator = $this->getCustomValidator($file, $rules);

        if ($validator) {
            try {
                if ($validator->fails()) {
                    return response()->json([
                        'success' => false,
                        'error'   => implode("\n", array_get($validator->getMessageBag()->toArray(), 'file', [])),
                    ]);
                }
            } catch (Exception $e) {
                cms()->log('error', "Error applying validation custom rules for uploaded file", [
                    'file'  => $storePath,
                    'rules' => $rules,
                ]);
                return response()->json([
                    'success' => false,
                    'error'   => cms_trans('upload.error.validation-failed'),
                ]);
            }
        }

        $path = $file->move($storeDir, $fileName);

        if (false === $path || ! $this->files->exists($storePath)) {
            // @codeCoverageIgnoreStart
            cms()->log('error', "Error moving uploaded file to {$storePath}");
            return response()->json([
                'success' => false,
                'error'   => cms_trans('upload.error.upload-failed'),
            ]);
            // @codeCoverageIgnoreEnd
        }

        $data = [
            'reference' => $request->input('reference'),
            'name'      => $request->input('name'),
            'uploader'  => $this->core->auth()->user()->getUsername(),
            'file_size' => $this->files->exists($path) ? $this->files->size($path) : null,
        ];

        if ( ! ($record = $this->fileRepository->create($path, $data))) {
            // @codeCoverageIgnoreStart
            cms()->log('error', "Error saving record for uploaded file at {$storePath}");
            return response()->json([
                'success' => false,
                'error'   => cms_trans('upload.error.saving-record-failed'),
            ]);
            // @codeCoverageIgnoreEnd
        }

        if ($this->sessionGuard->enabled()) {
            $this->sessionGuard->link($record->getKey());
        }

        $this->performGarbageCollection();

        return response()->json([
            'success'   => true,
            'id'        => $record->getKey(),
            'reference' => $record->reference,
            'name'      => $record->name,
            'size'      => $record->file_size,
            'mimetype'  => $mimeType,
        ]);
    }
193703
public function store(Request $request)
    {
        $this->validate($request, Role::$rules, Role::$messages);

        $this->createEntry(Role::class, $request->all());

        return redirect_to_resource();
    }
581484
public function uploadAction(Request $request)
    {
        $this->checkToolAccess();

        $files = $request->files->all();
        $data = null;

        if (1 === count($files)) {
            foreach ($files as $file) {
                $data = file_get_contents($file);
            }
        } else {
            return new JsonResponse('No uploaded file', 500);
        }

        return new JsonResponse($data, 200);
    }
959547
public function filesAction(Request $request)
    {
        $id = $request->query->get('id');
        $em = $this->getDoctrine()->getManager();

        $files = $this->getDoctrine()->getRepository('ClasticMediaBundle:File')
            ->findBy(array(
                'directory' => $em->getReference('ClasticMediaBundle:Directory', $id),
            ));

        $data = array_map(function (File $file) {
            return array(
                'id' => $file->getId(),
                'text' => $file->getName(),
                'path' => '/uploads/documents/'.$file->getPath(),
            );
        }, $files);

        return new JsonResponse($data);
    }
650266
public function index(Request $request)
    {
        $currentPath = $request->get('path');
        $dir         = storage_path('app/public/' . $currentPath);
        $imageFiles  = $this->getImageFiles($dir);

        foreach (Finder::create()->in($dir)->sortByType()->directories() as $file) {
            $imageFiles->name($file->getBaseName());
        }

        $files = new Collection;
        $parts = explode('/', $currentPath);
        array_pop($parts);
        if ($parts <> '' && $currentPath <> '') {
            $files->push([
                'name'    => '.. Up',
                'relPath' => implode('/', $parts),
                'type'    => 'dir',
                'url'     => \Storage::url($currentPath),
            ]);
        }

        foreach ($imageFiles as $file) {
            $path = str_replace(storage_path('app/public/'), '', $file->getRealPath());
            $files->push([
                'name'    => $file->getFilename(),
                'relPath' => $path,
                'type'    => $file->getType(),
                'url'     => \Storage::url($path),
            ]);
        }

        return response()->json($files->groupBy('type'));
    }
1023224
public function store(PropertyRequest $request)
    {
        $property = Property::create($request->all());

        return (new PropertyResource($property));
    }
1283509
public function store(Request $request)
    {
        $this->manager->resetPath($request->folder);

        if (empty($request->name)) {
            return $this->json('Name property is required.', 422);
        }

        if (!$this->manager->blobExists()) {
            return $this->json('Folder not found.', 404);
        }

        $result = $this->manager->makeDirectory($request->name)->fullDetails();

        return $this->json($result);
    }
1175076
public function postAction(Request $request)
    {
        $file = new File();
        $request = $this->requestManager->updateFileRequest($request);

        if ($formData = $request->get('metadata')) {
            $file = $this->restUtils->validateRequest($formData, $this->getModel());
        }

        /** @var FileModel $model */
        $model = $this->getModel();
        $file = $this->fileManager->handleSaveRequest($file, $request, $model);

        // Set status code and content
        $response = $this->getResponse();
        $response->setStatusCode(Response::HTTP_CREATED);
        $response->headers->set(
            'Location',
            $this->getRouter()->generate('gravitondyn.file.rest.file.get', array('id' => $file->getId()))
        );
        return $response;
    }
292920
public function store(Request $request)
    {
        if ($request->hasFile('file')) {
            $file = $request->file('file');
            $this->manager->resetPath($request->path);

            if (!$this->manager->isSafe($file->getClientOriginalExtension(), $file->getMimeType())) {
                return $this->json(['Uploading file is not safe and could not be uploaded.'], 422);
            }

            $blob = $this->manager->upload($file);

            return $this->json($blob);
        }

        return $this->json(['File not presented for upload.'], 422);
    }
309450
public function store(Request $request)
    {
        $response = $this->repository->create($request->all());
        return Response::apiResponse([
            'data' => $response
        ]);
    }
543289
public function upload(Request $request)
    {
        $validation = $this->validation->check([
            'location' => [],
        ]);

        if (!$validation['errors']) {
            $file = $request->file('location');
            $fileSaved = $this->fileService->saveFile($file, 'files/');
            $fileSaved['name'] = CryptoService::encrypt($fileSaved['name']);
            $fileSaved['mime'] = $file->getClientMimeType();
            $fileSaved['size'] = $file->getClientSize();
            $response = $this->responseService->apiResponse('success', $fileSaved);
        } else {
            $response = $this->responseService->apiErrorResponse($validation['errors'], $validation['inputs']);
        }

        return $response;
    }
1128934
public function store(Request $request)
    {
        $filePath = $this->handleImageUpload($request->file('theme_zip_file'));

        $zip = new \ZipArchive();

        if ($zip->open($filePath) === true) {
            $extractPath = base_path('themes');
            $zip->extractTo($extractPath);
            $zip->close();
        } else {
            throwException('Error in Zip Extract error.');
        }

        return redirect()->route('admin.theme.index');
    }
576939
public function store(Request $request)
    {
        $this->getFormRequestInstance();

        DB::beginTransaction();
        try {
            $instance = $this->repository->create($request->all());
            $model = $instance[1];
            $number = $model->{$model->getRouteKeyName()};
            $mergedRequest = $this->uploadFiles($request, $model);
            $this->updateOrCreateRelations($mergedRequest, $model);
        } catch (\Exception $e) {
            DB::rollback();

            $message = $this->storeFailedMessage($e->getMessage());
            throw new ResourceControllerException($message);
        }

        DB::commit();

        $message = $this->storeSuccessfulMessage($number);

        if ($request->wantsJson()) {
            $data = [
                $model
            ];

            return $this->validSuccessJsonResponse($message, $data);
        }

        return redirect()->route($this->getRedirectionRoute())
            ->with($this->successFlashMessageKey, $message);
    }
1147475
public function store(Create $request)
    {
        $data = $request->all();

        unset($data['image']);

        if (\Input::hasFile('image')) {
            // upload image
            $this->uploader->upload('image')->save('images/articles');

            $data['image'] = $this->uploader->getFilename();
        }

        $data['user_id'] = \Auth::id();
        $data['slug'] = Str::slug($data['title']);

        $this->repository->create($data);

        return $this->redirect(isOnPages() ? 'pages.index' : 'articles.index');
    }