download($path); } public function store(FileStoreRequest $request, ImageProcessor $imageProcessor) { $request->file = $imageProcessor->convertImage($request->file->path(),'/tmp/' . app()->uuid . '.' . app()->collection->ext); if (!is_null(app()->collection->process)) { $request->file = $imageProcessor->process($request->file->path(),'/tmp/' . app()->uuid. '.' . app()->collection->ext, app()->collection->process); } DB::transaction(function () use ($request) { $uuid = app()->uuid; $request->resourceFile = File::create([ 'uuid' => $uuid, 'original_name' => $request->name, 'public' => $request->public, 'ext' => $request->file->extension(), 'mimetype' => $request->file->getMimeType(), 'width' => getimagesize($request->file)[0], 'height' => getimagesize($request->file)[1], 'file_size' => $request->file->getSize(), 'sort' => $request->file->getSize(), 'alts' => $request->alts, 'description' => $request->description, 'user_id' => auth()->id(), 'ip' => $request->ip(), 'collection_id' => app()->collection->id, 'published_at' => $request->published_at, 'server_path' => '/' . date('y') . '/' . date('m') . '/', ]); if (!app()->collection->tmp_support && app()->collection->count == 1) { File::where('user_id', auth()->id())->delete(); } $storedFile = Storage::disk(app()->collection->disk)->putFileAs('', $request->file,$request->resourceFile->server_path . $request->resourceFile->uuid . '.' . app()->collection->ext); if (app()->collection->public) { Storage::disk(app()->collection->disk)->setVisibility($storedFile, 'public'); } }); return new FileResource($request->resourceFile); } public function update(Request $request, $id) { // } public function destroy($id) { // } }