Store a newly created Files in storage.

@param FileRequest $request

@return 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;
    }
686398
public function store(HCResourceRequest $request): JsonResponse
    {
        $this->connection->beginTransaction();

        try {
            $record = $this->service->upload(
                $request->getFile(),
                $request->getLastModified(),
                null,
                null,
                $request->input('previewSizes', [])
            );

            $data = $request->all();

            if (sizeof($data) > 2) {
                array_forget($data, ['file', 'lastModified']);

                /** @var \HoneyComb\Resources\Models\HCResource $recordM */
                $recordM = $this->service->getRepository()->find($record['id']);
                $recordM->update($data);

                $translation = [
                    'language_code' => app()->getLocale(),
                    'label' => '',
                ];

                foreach ($data as $key => $value) {
                    if (strpos($key, 'translation_') !== false) {
                        $key = explode('_', $key)[1];

                        $translation[$key] = $value;
                    } else {
                        if ($key === 'tags') {
                            $recordM->tags()->sync(explode(',', $value));
                        }
                    }
                }

                $recordM->translation()->create($translation);
            }

            $this->connection->commit();
        } catch (\Throwable $exception) {
            $this->connection->rollBack();

            report($exception);

            return $this->response->error($exception->getMessage());
        }

        event(new HCResourceCreated($record));

        $response = [
            'id' => $record['id'],
            'url' => route('resource.get', $record['id']),
            'storageUrl' => $record['storageUrl'],
        ];

        return $this->response->success('Uploaded', $response);
    }
533510
public function store(Request $request)
    {
        // Instantiate a new model item.
        $modelClass = $this->getModelClass();
        $item = new $modelClass;

        // Validate the request.
        $this->validate($request, $item->getValidationRules());

        // Create the new item.
        $itemData = $request->all();
        $item->fill($itemData);
        $item->save();

        $newItem = call_user_func([$this->getModelClass(), 'find'], $item->id)->toArray();
        return $this->generateResponse($this->modelTableName, $newItem);
    }
940655
public function uploadArchiveAction(Request $request)
    {
        $files = $request->files->all();

        foreach ($files as $file) {
            $object = $this->crud->create(
                PublicFile::class,
                [],
                ['file' => $file]
            );
        }

        $zip = new \ZipArchive();
        $zip->open($this->fileUtils->getPath($object));
        $json = $zip->getFromName('workspace.json');
        $zip->close();

        $data = json_decode($json, true);
        $data['archive'] = $this->serializer->serialize($object);

        return new JsonResponse($data);
    }
123980
public function handleFiles(Request &$request)
    {
        $files = $request->files->all();
        if(!empty($files)) {
            $metadata = $this->handlerService->handleFiles($files);
            $request->headers->add(['file-meta-data' => json_encode($metadata)]);
        }
    }
593219
public function uploadFiles(UploadFileRequest $request)
    {
        try {
            $files = $request->file('files');
            $folder = $request->get('folder', '/');
            $uploadedFiles = new UploadedFiles($files);

            $response = $this->mediaManager->saveUploadedFiles($uploadedFiles, $folder);
            if ($response != 0) {
                $response = trans('media-manager::messages.upload_success', ['entity' => $response.' New '.str_plural('File', $response)]);
            }

            $errors = $this->mediaManager->errors();
            if (!empty($errors)) {
                return $this->errorResponse($errors, $response);
            }

            return ['success' => $response];
        } catch (\Exception $e) {
            return $this->errorResponse([$e->getMessage()]);
        }
    }
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);
    }
115982
public function store(Request $request)
    {
        $attributes = request()->validate(News::$rules, News::$messages);

        $news = $this->createEntry(News::class, $attributes);

        return redirect_to_resource();
    }
1023224
public function store(PropertyRequest $request)
    {
        $property = Property::create($request->all());

        return (new PropertyResource($property));
    }
1061594
public function store(CreateUserRequest $request)
    {
        $input = $request->all();

        $user = $this->repository->create($input);
        $user->load($request->getWith());

        return $this->sendResponse($user, 'User saved successfully.');
    }
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');
    }
824365
public function store(Request $request)
	{
		$attributes = request()->validate(Settings::$rules, Settings::$messages);

        $setting = $this->createEntry(Settings::class, $attributes);

        log_activity('Setting Created', 'A Setting was successfully created', $setting);

        return redirect_to_resource();
	}
844366
public function store(CreateUserRequest $request)
    {
        $user = User::create([
            'name' => $request->input('name'),
            'email' => $request->input('email'),
            'password' => bcrypt($request->input('password')),
        ]);

        event(new UserCreated($user));

        return Response::json(['created' => true ]);
    }
808384
public function store()
    {
        try {
            $request = app(FileStoreRequest::class);
            $this->model->manageUpload($request->file('file'), $request->except('file'));
            return redirect()->route('admin.files.index')->withStatus(__('msg.uploaded_success'));
        } catch (ValidationException $e) {
            $message = $e->validator->errors()->first();
            return redirect()->back()->withInput()->withErrors($message);
        } catch (\Exception $e) {
            $message = 'owner' == user('role') ? $e->getMessage() : __('validation.uploaded');
            return redirect()->back()->withInput()->withErrors($message);
        }
    }
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);
    }
760984
public function fileAction(Request $request)
    {
        $fileId = $request->get('file_id');

        $volumeManager = $this->get('phlexible_media_manager.volume_manager');

        $volume = $volumeManager->getByFileId($fileId);
        $file = $volume->findFile($fileId);

        $debug = [
            ['key' => 'mimeType', 'value' => $file->getMimeType()],
            ['key' => 'mediaType', 'value' => strtolower($file->getMediaType())],
            ['key' => 'fileId', 'value' => $file->getId()],
            ['key' => 'folderId', 'value' => $file->getFolderId()],
        ];

        return new JsonResponse(['debug' => $debug]);
    }
1327545
public function fileZipAction(Request $request)
    {
        $fileIds = $request->get('data');
        $fileIds = json_decode($fileIds);

        $volumeManager = $this->get('phlexible_media_manager.volume_manager');
        $path = $this->container->getParameter('phlexible_media_manager.temp_dir');

        $filesystem = new Filesystem();
        $filesystem->mkdir($path);

        $firstFileId = current($fileIds);
        $volume = $volumeManager->getByFileId($firstFileId);
        $firstFile = $volume->findFile($firstFileId);
        $folder = $volume->findFolder($firstFile->getFolderId());

        $filename = $path.'files_'.$folder->getName().'_'.date('YmdHis').'.zip';

        $files = [];
        foreach ($fileIds as $fileId) {
            $file = $volume->findFile($fileId);

            $files[$folder->getName().'/'.$file->getName()] = $file->getPhysicalPath();
        }

        $zippy = Zippy::load();
        $zippy->create($filename, $files);

        return new ResultResponse(true, 'Zip finished', ['filename' => basename($filename)]);
    }