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


PHP Storage::disk方法代码示例

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


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

示例1: removeMedia

 public function removeMedia($file)
 {
     $this->removeCache($file);
     if (Storage::disk(config('medias.disk'))->exists($file)) {
         Storage::disk(config('medias.disk'))->delete($file);
     }
 }
开发者ID:escapework,项目名称:laramedias,代码行数:7,代码来源:MediasDestroyerService.php

示例2: upload

 /**
  * 文件上传
  * @throws \Exception
  */
 public function upload()
 {
     // 要上传的空间
     $bucket = "genffy";
     // 生成上传 Token
     $token = self::auth()->uploadToken($bucket);
     // 要上传文件的本地路径
     $floder = Storage::disk("local");
     $filePath = $floder->getDriver()->getAdapter()->getPathPrefix() . "头像.png";
     // 上传到七牛后保存的文件名
     $key = md5($filePath) . ".png";
     // 初始化 UploadManager 对象并进行文件的上传。
     $uploadMgr = new UploadManager();
     list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
     echo "\n====> putFile result: \n";
     if ($err !== null) {
         var_dump($err);
     } else {
         // 返回下载链接
         $time = time() + 7 * 24 * 60 * 60;
         $url = self::QI_NIU_DOMAIN . $ret["key"] . "?e={$time}";
         $sign = hash_hmac('sha1', $url, self::getKey("secret"), true);
         $token = self::getKey("access") . ":" . self::urlsafe_base64_encode($sign);
         $realUrl = $url . "&token={$token}";
         echo "<a href='{$realUrl}' target='_blank'>头像</a>";
     }
 }
开发者ID:picexif,项目名称:tushuo,代码行数:31,代码来源:QiniuController.php

示例3: __construct

 public function __construct(AssetRepository $assetRepository, PhpRepository $mimeDetect, OrganizationRepository $organizationRepository)
 {
     $this->assetRepo = $assetRepository;
     $this->orgRepo = $organizationRepository;
     $this->disk = Storage::disk(config('assets.uploads.storage'));
     $this->mimeDetect = $mimeDetect;
 }
开发者ID:bakgat,项目名称:notos,代码行数:7,代码来源:AssetsManager.php

示例4: handle

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $host = config('database.connections.mysql.host');
     $database = config('database.connections.mysql.database');
     $username = config('database.connections.mysql.username');
     $password = config('database.connections.mysql.password');
     $backupPath = config('backup.path');
     $cloudStorage = config('backup.cloud-storage');
     $cloudDisk = config('backup.cloud-disk');
     $cloudPath = config('backup.cloud-path');
     $keepLocal = config('backup.keep-local');
     $path = config('backup.path');
     $filename = $database . '_' . empty(trim($this->argument('filename'))) ? \Carbon\Carbon::now()->format('YmdHis') : trim($this->argument('filename'));
     $mysqldumpCommand = "mysqldump -e -f -h {$host} -u {$username} -p{$password} {$database} > {$backupPath}{$filename}.sql";
     exec($mysqldumpCommand);
     $this->info('Backup completed!');
     if ($cloudStorage) {
         $fileContents = file_get_contents("{$backupPath}{$filename}.sql");
         Storage::disk($cloudDisk)->put("{$cloudPath}{$filename}.sql", $fileContents);
         if (!$keepLocal) {
             $rmCommand = "rm {$backupPath}{$filename}.sql";
             exec($rmCommand);
         }
         $this->info('Backup uploaded to cloud storage!');
     }
 }
开发者ID:paulvl,项目名称:mysql,代码行数:31,代码来源:Dump.php

示例5: saveFile

 /**
  * Saves File.
  *
  * @param string $fileName File input name
  * @param string $location Storage location
  *
  * @return array
  */
 public static function saveFile($fileName, $directory = '', $fileTypes = [])
 {
     if (is_object($fileName)) {
         $file = $fileName;
         $originalName = $file->getClientOriginalName();
     } else {
         $file = Request::file($fileName);
         $originalName = false;
     }
     if (is_null($file)) {
         return false;
     }
     if (File::size($file) > Config::get('quarx.maxFileUploadSize', '')) {
         throw new Exception('This file is too large', 1);
     }
     if (substr($directory, 0, -1) != '/') {
         $directory .= '/';
     }
     $extension = $file->getClientOriginalExtension();
     $newFileName = md5(rand(1111, 9999) . time());
     // In case we don't want that file type
     if (!empty($fileTypes)) {
         if (!in_array($extension, $fileTypes)) {
             throw new Exception('Incorrect file type', 1);
         }
     }
     Storage::disk(Config::get('quarx.storage-location', 'local'))->put($directory . $newFileName . '.' . $extension, File::get($file));
     return ['original' => $originalName ?: $file->getFilename() . '.' . $extension, 'name' => $directory . $newFileName . '.' . $extension];
 }
开发者ID:YABhq,项目名称:Quarx,代码行数:37,代码来源:FileService.php

示例6: boot

 protected static function boot()
 {
     parent::boot();
     static::created(function ($model) {
         $storage = Storage::disk('gallery');
         $path = 'galleries/' . str_slug($model->title);
         if (!$storage->exists($path)) {
             $storage->makeDirectory($path);
             return true;
         }
         return false;
     });
     static::updating(function ($model) {
         $changed = $model->getDirty();
         $original = $model->getOriginal();
         $storage = Storage::disk('gallery');
         $existsPath = 'galleries/' . $changed['slug'];
         if (!$storage->exists($existsPath)) {
             $oldPath = public_path() . '/gallery_assets/galleries/' . $original['slug'];
             $newPath = public_path() . '/gallery_assets/galleries/' . $changed['slug'];
             if (rename($oldPath, $newPath)) {
                 $model->setAttribute('slug', $changed['slug']);
                 return true;
             }
         }
         return false;
     });
     static::deleting(function ($model) {
         $storage = Storage::disk('gallery');
         $path = 'galleries/' . str_slug($model->title);
         if ($storage->exists($path)) {
             $storage->deleteDirectory($path);
         }
     });
 }
开发者ID:Krato,项目名称:kgallery,代码行数:35,代码来源:GalleryEvents.php

示例7: updateFile

 public function updateFile($id, Request $request)
 {
     $file = $request->file('updateFile');
     $entry = FileRecord::where('id', '=', $id)->firstOrFail();
     Storage::disk('local')->put($entry->owner_id . $entry->id . $entry->filename . "/" . ($entry->total_versions + 1), File::get($file));
     $entry->total_versions = $entry->total_versions + 1;
     $entry->public_version = $entry->total_versions;
     $docVersions = (array) json_decode($entry->version_details);
     $version = $entry->total_versions - 1;
     $note = $request->updateDetails;
     $date = Carbon::now();
     $user = Auth::User()->fname . ' ' . Auth::User()->lname;
     $versionArray = [$version => array('user' => $user, 'stamp' => $date, 'note' => $note)];
     $finalVer = json_encode(array_merge($docVersions, $versionArray));
     $entry->version_details = $finalVer;
     $entry->save();
     $admins = User::get()->where('user_type_id', 1);
     foreach ($admins as $admin) {
         $uploader = Auth::user()->fname . " " . Auth::user()->lname . " (" . Auth::user()->username . ")";
         Mail::queue('mail.adminFileUpdate', ['uploader' => $uploader, 'fileName' => $entry->filename, 'id' => $entry->id, 'version' => $entry->public_version], function ($message) use(&$admin) {
             $message->to($admin->email, $admin->fname)->subject('New File Update');
         });
     }
     return redirect('/');
 }
开发者ID:LarsNorlander,项目名称:documenter,代码行数:25,代码来源:FileController.php

示例8: 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

示例9: 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

示例10: getLatest

 public static function getLatest()
 {
     return self::remember('latest', function () {
         $meta = json_decode(Storage::disk('local')->get('subtitles/meta.json'), true);
         return $meta['latest'];
     });
 }
开发者ID:kcwikizh,项目名称:kcwiki-api,代码行数:7,代码来源:SubtitleCache.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: 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

示例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: uploadW9

 public function uploadW9(Request $request, $link, $app_name, $aff_code)
 {
     $affiliate_row = Affiliate::where('external_link', '=', $link)->first();
     if ($affiliate_row == null) {
         return redirect('error');
     }
     //$user_infusionsoft = UserInfusionsoft::where('app_name','=', $app_name)->first();
     $user_infusionsoft = $affiliate_row->infusionsoft_user;
     $app_infusionsoft = new iSDK();
     if (!$app_infusionsoft->cfgCon($user_infusionsoft->app_name, $user_infusionsoft->app_apikey)) {
         return redirect('error');
     }
     $file = $request->file('w9file');
     if ($file) {
         $extension = $file->getClientOriginalExtension();
         $mimeType = $file->getMimeType();
         if (strtolower($extension) != 'pdf' || $mimeType != 'application/pdf') {
             return redirect(URL::to('aff/' . $link . '/' . $app_name . '/' . $aff_code))->with('error', 'You can upload pdf files only.');
         }
         Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file));
         $affiliate_row->w9_file_original_name = $file->getClientOriginalName();
         $affiliate_row->w9_file = $file->getFilename() . '.' . $extension;
         $affiliate_row->save();
         return redirect(URL::to('aff/' . $link . '/' . $app_name . '/' . $aff_code))->with('success', 'Congratulations! Your W9 is uploaded.');
     }
     return redirect(URL::to('aff/' . $link . '/' . $app_name . '/' . $aff_code))->with('error', 'No file is selected.');
 }
开发者ID:ruben-verhagen,项目名称:easy-affiliates,代码行数:27,代码来源:PublicAffiliateController.php

示例15: 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


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