当前位置: 首页>>代码示例>>PHP>>正文


PHP Facades\Storage类代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Storage的典型用法代码示例。如果您正苦于以下问题:PHP Storage类的具体用法?PHP Storage怎么用?PHP Storage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Storage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Delete the directory with the filename and all files inside
  * Fire FileWasDeleted Event
  *
  */
 public function handle()
 {
     if (Storage::exists($this->getFileDirectory())) {
         Storage::deleteDirectory($this->getFileDirectory());
     }
     event(new FileWasDeleted($this->filename));
 }
开发者ID:phileserver,项目名称:core,代码行数:12,代码来源:DeleteFile.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  * @throws ImageFailedException
  * @throws \BB\Exceptions\FormValidationException
  */
 public function store()
 {
     $data = \Request::only(['user_id', 'category', 'description', 'amount', 'expense_date', 'file']);
     $this->expenseValidator->validate($data);
     if (\Input::file('file')) {
         try {
             $filePath = \Input::file('file')->getRealPath();
             $ext = \Input::file('file')->guessClientExtension();
             $mimeType = \Input::file('file')->getMimeType();
             $newFilename = \App::environment() . '/expenses/' . str_random() . '.' . $ext;
             Storage::put($newFilename, file_get_contents($filePath), 'public');
             $data['file'] = $newFilename;
         } catch (\Exception $e) {
             \Log::error($e);
             throw new ImageFailedException($e->getMessage());
         }
     }
     //Reformat from d/m/y to YYYY-MM-DD
     $data['expense_date'] = Carbon::createFromFormat('j/n/y', $data['expense_date']);
     if ($data['user_id'] != \Auth::user()->id) {
         throw new \BB\Exceptions\FormValidationException('You can only submit expenses for yourself', new \Illuminate\Support\MessageBag(['general' => 'You can only submit expenses for yourself']));
     }
     $expense = $this->expenseRepository->create($data);
     event(new NewExpenseSubmitted($expense));
     return \Response::json($expense, 201);
 }
开发者ID:paters936,项目名称:BBMembershipSystem,代码行数:33,代码来源:ExpensesController.php

示例3: actualizar

 public function actualizar($id, Request $request)
 {
     try {
         $rules = array('nombre' => array('required', 'string', 'min:5', 'unique:promociones,nombre' . $id), 'descripcion' => array('required', 'string', 'min:30'), 'imagen' => array('image', 'image_size:>=300,>=300'), 'inicio' => array('date'), 'fin' => array('date', 'after: inicio'));
         $this->validate($request, $rules);
         $registro = Promociones::find($id);
         $registro->nombre = \Input::get('nombre');
         $registro->descripcion = \Input::get('descripcion');
         if ($archivo = BRequest::file('foto')) {
             $foto = BRequest::file('imagen');
             $extension = $foto->getClientOriginalExtension();
             Storage::disk('image')->put($foto->getFilename() . '.' . $extension, File::get($foto));
             $registro->imagen = $foto->getFilename() . '.' . $extension;
         }
         if ($inicio = \Input::get('inicio')) {
             $registro->inicio = \Input::get('inicio');
         }
         if ($inicio = \Input::get('fin')) {
             $registro->fin = \Input::get('fin');
         }
         $registro->save();
         return \Redirect::route('adminPromociones')->with('alerta', 'La promocion ha sido modificada con exito!');
     } catch (ValidationException $e) {
         return \Redirect::action('PromocionesCtrl@editar', array('id' => $id))->withInput()->withErrors($e->get_errors());
     }
 }
开发者ID:JFSolorzano,项目名称:Acordes,代码行数:26,代码来源:PromocionesCtrl.php

示例4: add

 public function add(Request $request)
 {
     $name = Input::get('user_name');
     $id = Input::get('user_id');
     $text = Input::get('description');
     if ($request->hasFile('filefield')) {
         $file = $request->file('filefield');
         $entry = new Fileentry();
         $filename = time() . '.' . $file->getClientOriginalExtension();
         $extension = $file->getClientOriginalExtension();
         //			Image::make($file)->orientate()->save(public_path('recipe/'. $filename));
         Storage::disk('local')->put($file->getFileName() . '.' . $extension, File::get($file));
         $entry->mime = $file->getClientMimeType();
         $entry->original_filename = $file->getClientOriginalName();
         $entry->filename = $file->getFilename() . '.' . $extension;
     }
     $entry->user_name = $name;
     $entry->user_id = $id;
     $entry->description = $text;
     $entry->save();
     //		$file = Request::file('filefield');
     //		$extension = $file->getClientOriginalExtension();
     //		Storage::disk('local')->put($file->getFilename().'.'.$extension,  File::get($file));
     //		$entry = new Fileentry();
     //		$entry->mime = $file->getClientMimeType();
     //		$entry->original_filename = $file->getClientOriginalName();
     //		$entry->filename = $file->getFilename().'.'.$extension;
     //		$entry->user_name = $name;
     //		$entry->user_id = $id;
     //		$entry->description = $text;
     //
     //		$entry->save();
     return redirect('/');
 }
开发者ID:legendjordy,项目名称:cooking,代码行数:34,代码来源:FileEntryController.php

示例5: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Storage::extend('bos', function ($app, $config) {
         $client = new BosClient($config);
         return new Filesystem(new BosAdapter($client, $config));
     });
 }
开发者ID:7keys,项目名称:qtools,代码行数:12,代码来源:BosServiceProvider.php

示例6: add

 public function add()
 {
     $file = Request::file('file');
     if (Request::hasFile('file')) {
         $extension = $file->getClientOriginalExtension();
         Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
         $entry = new \App\File();
         $entry->mime = $file->getClientMimeType();
         $entry->original_filename = $file->getClientOriginalName();
         $entry->filename = $file->getFilename() . '.' . $extension;
         $entry->save();
         $part = new Part();
         $part->file_id = $entry->id;
         $part->name = Request::input('name');
         $part->sku = Request::input('sku');
         $part->make = Request::input('make');
         $part->year = Request::input('year');
         $part->condition = Request::input('condition');
         $part->description = Request::input('description');
         $part->price = Request::input('price');
         $part->imageurl = Request::input('imageurl');
         if (Request::has('price')) {
             $part->save();
         }
     }
     return redirect('/admin/part');
 }
开发者ID:kilis,项目名称:carshop,代码行数:27,代码来源:PartController.php

示例7: downloadFileInWindowsNT

 protected function downloadFileInWindowsNT(TFFile $file)
 {
     $client = new Client();
     try {
         $response = $client->get($file->source, ['verify' => false]);
     } catch (\Exception $e) {
         $error = 'TFDownloader: Downloading file failed, url is %s, msg is %s.';
         $error = sprintf($error, $file->source, $e->getMessage());
         Log::error($error);
         $file->state = 'error';
         $file->error = $error;
         $file->save();
         return;
     }
     if ($response->getStatusCode() == 200) {
         $location = 'file/' . $file->name;
         Storage::put($location, $response->getBody());
         $file->state = 'downloaded';
         $file->location = $location;
         $file->save();
         return;
     } else {
         $error = 'TFDownloader: Bad HTTP response code in downloading videos, url is %s, status code is %d.';
         $error = sprintf($error, $file->source, $response->getStatusCode());
         Log::error($error);
         $file->state = 'error';
         $file->error = $error;
         $file->save();
         return;
     }
 }
开发者ID:roslairy,项目名称:tumfetch,代码行数:31,代码来源:TFDownloader.php

示例8: resize

 public function resize($image)
 {
     $width = config('medias.max_size.width');
     $height = config('medias.max_size.height');
     // this orientate method needs to be called because sometimes
     // images uploaded came rotated, but need to be ajusted
     $img = $this->image->make(Storage::disk(config('medias.disk'))->get($image))->orientate();
     if ($img->width() <= $width && $img->height() <= $height) {
         return;
     }
     if ($img->width() > $width && $img->height() > $height) {
         $img->resize($width, $height, function ($constraint) {
             $constraint->aspectRatio();
         });
         Storage::disk(config('medias.disk'))->put($image, $img->stream());
         return;
     }
     if ($img->width() > $width) {
         $height = null;
     } elseif ($img->height() > $height) {
         $width = null;
     }
     $img->resize($width, $height, function ($constraint) {
         $constraint->aspectRatio();
     });
     Storage::disk(config('medias.disk'))->put($image, $img->stream());
 }
开发者ID:escapework,项目名称:laramedias,代码行数:27,代码来源:MediasResizeService.php

示例9: upload_file

function upload_file($file)
{
    $extension = $file->getClientOriginalExtension();
    $filename = $file->getFilename() . '.' . $extension;
    Storage::disk('local')->put($filename, File::get($file));
    return $filename;
}
开发者ID:savitskayads,项目名称:skillcamp,代码行数:7,代码来源:helpers.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $validator = Validator::make($request->all(), ['customer_id' => 'required|numeric', 'location' => 'required|max:100', 'name' => 'required|max:100', 'description' => 'required|max:150', 'content' => 'required|in:complete,modify', 'type' => 'required|in:file,url']);
     if ($validator->fails()) {
         return redirect('admin/feeds/create')->withInput()->withErrors($validator);
     }
     if ($request->hasFile('feed')) {
         //
         $file = $request->file('feed');
         $extension = $file->getClientOriginalExtension();
         Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
         //return Redirect::to('admin/users/create')
         //->withInput()
         //->withErrors(array('message' => 'Login field is required.'));
         //http://stackoverflow.com/questions/18367769/how-to-use-witherrors-with-exception-error-messages-in-laravel4
     }
     //$input = $request->all();
     //Feed::create($input);
     $feed = new Feed();
     $feed->customer_id = $request->customer_id;
     $feed->name = $request->name;
     $feed->location = $request->location;
     $feed->type = $request->type;
     $feed->content = $request->content;
     $feed->description = $request->description;
     $feed->save();
     //$feed = new Feed(Input::all())->save();
     Activity::log(Auth::user()->name . ' Add feed:' . $request->name);
     //Activity::log(Auth::user()->name.' Add file:'.$file->name);
     return redirect('admin/feeds');
 }
开发者ID:shihqi,项目名称:fms,代码行数:38,代码来源:FeedController.php

示例11: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // get directory path from file
     $goalDirectory = pathinfo($this->path, PATHINFO_DIRNAME);
     // get all subdirectories
     $directories = Storage::disk('powerimage')->allDirectories($goalDirectory);
     // delete resized iamges
     foreach ($directories as $directory) {
         if ($goalDirectory == '.') {
             // root directory
             $checkPath = $directory . '/' . $this->path;
         } else {
             // subdirectory
             $checkPath = str_replace($goalDirectory, $directory, $this->path);
         }
         if (Storage::disk('powerimage')->exists($checkPath)) {
             Storage::disk('powerimage')->delete($checkPath);
         }
     }
     // delete original image
     if (Storage::disk('powerimage')->exists($this->path)) {
         Storage::disk('powerimage')->delete($this->path);
         return true;
     }
     return false;
 }
开发者ID:alcodo,项目名称:powerimage,代码行数:31,代码来源:DeleteImage.php

示例12: handle

 /**
  * Rename the file directory to rename the file in the system
  *
  */
 public function handle()
 {
     if (Storage::exists($this->getOldFileDirectory())) {
         Storage::move($this->getOldFileDirectory(), $this->getNewFileDirectory());
     }
     event(new FileWasRenamed($this->from, $this->to));
 }
开发者ID:phileserver,项目名称:core,代码行数:11,代码来源:RenameFile.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $file = Request::file('xmlfile');
     $type = Input::get('type');
     $userid = Input::get('userid');
     $alpha = Input::get('alpha');
     $extension = $file->getClientOriginalExtension();
     $oname = $file->getClientOriginalName();
     Storage::disk('local')->put("uploads/" . $file->getClientOriginalName(), File::get($file));
     $parser = new Parser();
     $contents = Storage::get("uploads/" . $file->getClientOriginalName());
     $rawxml = $parser->xml($contents);
     $importer = new Importer();
     if ($type == 'recipes') {
         $importer->parseRecipe($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'blocks') {
         $importer->parseBlocks($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'materials') {
         $importer->parseMaterial($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'items') {
         $importer->parseItems($rawxml, $userid, $alpha, 1);
     }
     //Flash::success('You successfully imported a '.$type.' xml file for 7 Days to Die Alpha '.$alpha.'!');
     return view('pages.import');
 }
开发者ID:jhansen69,项目名称:7Days,代码行数:33,代码来源:ImportController.php

示例14: upload

 public function upload()
 {
     $path = $this->folder . '/' . $this->newFileName;
     $content = file_get_contents($this->file->getRealPath());
     Storage::put($path, $content);
     return 'uploads/' . $path;
 }
开发者ID:ninjamonz,项目名称:laravel_catalog_example,代码行数:7,代码来源:UploadFile.php

示例15: get

 public function get($filename)
 {
     $entry = Fileentry::where('filename', '=', $filename)->firstOrFail();
     $file = Storage::disk('local')->get($entry->filename);
     //dd(Response($file, 200)->header('Content-Type', $entry->mine));
     return Response($file, 200)->header('Content-Type', $entry->mine);
 }
开发者ID:zc1415926,项目名称:FileStorage_Laravel,代码行数:7,代码来源:FileEntryController.php


注:本文中的Illuminate\Support\Facades\Storage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。