public function store(Request $request) { if ($request->has('droplet_id')) { $droplet = $this->dropletRepository->getById($request->get('droplet_id')); } else { $droplet = $this->dropletRepository->getOrCreateByHash($request->get('upload_hash'), Auth::id()); } if ($file = $request->file('file')) { $file_name = $file->getClientOriginalName(); $filesystem = filesystem()->init($droplet->filesystem()); try { // Does the source folder exist if (!$filesystem->has($droplet->present()->directory)) { $filesystem->createDir($droplet->present()->directory); } $filesystem->write($droplet->present()->directory . '/' . $file_name, file_get_contents($file->getRealPath())); $this->fileRepository->create($droplet->id, $droplet->storage_id, $file_name, $file->getMimeType(), $file->getSize()); if ($request->ajax()) { return response()->json($droplet->id, 200); } } catch (\Exception $e) { die($e->getMessage()); } return redirect()->back(); } }
public function share($dropletId) { $droplet = $this->dropletRepository->getById($dropletId); $class = 'with-top-pane with-bottom-pane'; return view('droplets.share', compact('droplet', 'class')); }