當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Storage::put方法代碼示例

本文整理匯總了PHP中Storage::put方法的典型用法代碼示例。如果您正苦於以下問題:PHP Storage::put方法的具體用法?PHP Storage::put怎麽用?PHP Storage::put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Storage的用法示例。


在下文中一共展示了Storage::put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

 public function create(array $data)
 {
     try {
         $this->validator->with($data)->passesOrFail(ValidatorInterface::RULE_CREATE);
         $projectFile = $this->repository->skipPresenter()->create($data);
         $this->storage->put($projectFile->getFileName(), $this->filesystem->get($data['file']));
         return ['success' => true];
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag(), "messageDev" => 'ValidatorException'];
     } catch (\Exception $e) {
         return ["error" => true, "message" => 'Falha ao gravar registro.', "messageDev" => $e->getMessage()];
     }
 }
開發者ID:jonasleitep4,項目名稱:curso-laravel-angular,代碼行數:13,代碼來源:ProjectFileService.php

示例2: uploadingLocalOrCloudFiles

 /**
  * Upload to Local or Cloud
  * 
  */
 protected function uploadingLocalOrCloudFiles($type, $file, $fname, $assetPath, $localDestination = "")
 {
     if (!config('veer.use_cloud_' . $type)) {
         return $file->move($localDestination . $assetPath, $fname);
     }
     \Storage::put($assetPath . '/' . $fname, file_get_contents($file->getPathName()));
 }
開發者ID:artemsk,項目名稱:veer-core,代碼行數:11,代碼來源:HelperTrait.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Suppression préalable des fichiers de upload par l'utilisation de la variable storage définie à l'aide de l'instruction public_path('upload') du fichier de configuration config\filesystem.php)
     $files = Storage::allFiles();
     //retroune un tableau des images de storage
     foreach ($files as $file) {
         Storage::delete($file);
     }
     //Supprimer toutes les lignes de la talble Pictures
     //        DB::table('pictures')->
     // Récupération d'un faker opétationnel
     // $faker = Faker\Factory::create();
     $products = Product::all();
     foreach ($products as $product) {
         // Stokage de l'image et récupération de l'uri
         $uri = str_random(15) . '_370x235.jpg';
         Storage::put($uri, file_get_contents('http://lorempixel.com/people/370/325/'));
         Picture::create(['product_id' => $product->id, 'uri' => $uri, 'title' => $this->faker->name]);
     }
     //        DB::table('pictures')->insert(
     //            [
     //                [
     //                    'product_id'  => '2' ,
     //                    'uri'         => $uri
     //                ],
     //            ]
     //        );
 }
開發者ID:lionel-kahan,項目名稱:Star-Wars,代碼行數:33,代碼來源:PictureTableSeeder.php

示例4: hookHandler

 /**
  * process request from gitlab webhook.
  *
  * @param  Request  $request
  * @return Response
  */
 public function hookHandler(Request $request)
 {
     $clientIp = !empty($request->header('X-Forwarded-For')) ?: $request->ip();
     Log::debug('hook received from ' . $clientIp);
     if ($this->isVerbose()) {
         dump($request);
     }
     $eventType = $request->headers->get('X-Gitlab-Event');
     if (is_null($eventType)) {
         $eventType = 'Push Hook';
     }
     // for debugging purpose.
     \Storage::put(str_replace(' ', '-', $eventType) . ".json", json_encode($request->json()->all(), JSON_PRETTY_PRINT));
     Log::info('eventType : ' . $eventType);
     if ($eventType == 'Push Hook') {
         return $this->pushHook($request);
     } elseif ($eventType == 'Tag Push Hook') {
         return $this->tagPushHook($request);
     } elseif ($eventType == 'Issue Hook') {
         return $this->issueHook($request);
     } elseif ($eventType == 'Note Hook') {
         return $this->noteHook($request);
     } elseif ($eventType == 'Merge Request Hook') {
         return $this->mergeRequestHook($request);
     }
     abort(500, 'Unknown Hook type : ' . $eventType);
 }
開發者ID:dw250100785,項目名稱:gitlab-jira-integration,代碼行數:33,代碼來源:GitlabController.php

示例5: createFile

 public function createFile(array $data)
 {
     $project = $this->repository->skipPresenter()->find($data['project_id']);
     $projectFile = $project->files()->create($data);
     $arquivo = $projectFile->id . "." . $data['extension'];
     \Storage::put($arquivo, \File::get($data['file']));
 }
開發者ID:danillosrangel,項目名稱:CodeProject-curso,代碼行數:7,代碼來源:ProjectService.php

示例6: creating

 public function creating(Media $media)
 {
     $uploadedFile = $this->request->file('media');
     $fileName = time() . $uploadedFile->getClientOriginalName();
     \Storage::put($fileName, file_get_contents($uploadedFile->getRealPath()));
     $media->url = url('uploads/' . $fileName);
 }
開發者ID:laravel-italia,項目名稱:site,代碼行數:7,代碼來源:UploadFileWhenAddingMedia.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if ($request->hasFile('file')) {
         $name = $request->file('file')->getClientOriginalName();
         \Storage::put($name, file_get_contents($request->file('file')->getRealPath()));
         return response()->json(['img' => $name]);
     }
 }
開發者ID:cesg,項目名稱:video-club,代碼行數:14,代碼來源:ImagenController.php

示例8: imageresponse

 public function imageresponse($name)
 {
     $randomcolor = RandomColor::one(array('luminosity' => 'light'));
     $img = \DefaultProfileImage::create($name, 256, $randomcolor, '#FFF');
     \Storage::put("profile.png", $img->encode());
     $headers = ['Content-Type' => 'image/jpeg', 'Content-Disposition' => 'inline', 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Pragma' => 'public'];
     return \Response::make($img, 200, $headers)->setTtl(60 * 30);
 }
開發者ID:axlyody,項目名稱:mikoci,代碼行數:8,代碼來源:HomeController.php

示例9: testDelete

 public function testDelete()
 {
     Storage::put('test-file.txt', 'what is this');
     $file = factory(\Yab\Quarx\Models\File::class)->make(['id' => 2, 'location' => ['file_a' => ['name' => CryptoService::encrypt('test-file.txt'), 'original' => 'test-file.txt', 'mime' => 'txt', 'size' => 24]]]);
     $this->call('POST', 'quarx/files', $file->getAttributes());
     $response = $this->call('DELETE', 'quarx/files/2');
     $this->assertEquals(302, $response->getStatusCode());
     $this->assertRedirectedTo('quarx/files');
 }
開發者ID:YABhq,項目名稱:Quarx,代碼行數:9,代碼來源:FilesTest.php

示例10: postAdd

 function postAdd()
 {
     $data = json_decode(\File::get(storage_path() . '/app/data.json'), 1);
     $product = ['name' => \Input::get('product_name'), 'quantity' => \Input::get('quantity'), 'price' => \Input::get('price'), 'timestamp' => date("Y-m-d H:i:s")];
     $data[] = $product;
     \Storage::put('data.json', json_encode($data));
     $product['timestamp'] = date("m/d/Y h:i a", strtotime($product['timestamp']));
     return \Response::json(['success' => true, 'data' => $product]);
 }
開發者ID:amermchaudhary,項目名稱:coalition,代碼行數:9,代碼來源:FormWebPage.php

示例11: makeUpload

 /**
  * Upload a single image
  * @param $file Object 
  * @param $path String
  * @return String Image name
  */
 private function makeUpload($file, $path)
 {
     // Get file name
     $filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
     // Create safe name with extension
     $name = str_slug($filename) . '.' . $file->getClientOriginalExtension();
     // Upload
     \Storage::put($path . $name, file_get_contents($file->getRealPath()));
     return $name;
 }
開發者ID:juanem1,項目名稱:uploader,代碼行數:16,代碼來源:Uploader.php

示例12: store

 /**
  *   Store the new game in the database
  *
  *   @param App\Http\Requests\StoreGameRequest $request
  *   @param App\Repositories\GameRepository $gameRepo
  *
  *   @return response
  */
 public function store(StoreGameRequest $request, GameRepository $gameRepo)
 {
     $game = $gameRepo->create($request);
     if ($request->hasFile('image') and $request->file('image')->isValid()) {
         $imageUri = 'games/logos/' . $game->id . '_logo_' . \Carbon\Carbon::now()->timestamp . '.' . $request->file('image')->getClientOriginalExtension();
         \Storage::put($imageUri, file_get_contents($request->file('image')->getRealPath()));
         $game->logo = $imageUri;
         $game->save();
     }
     return redirect()->route('admin.games.index')->with('success', $game->name . " has been created");
 }
開發者ID:BrantWladichuk,項目名稱:gamechalleng.es,代碼行數:19,代碼來源:GameController.php

示例13: rollback

 /**
  * rollback
  */
 public function rollback()
 {
     $this->storage->remove($this->uri, $this->options);
     if (is_null($this->previous)) {
         $this->storage->remove($this->uri);
     } else {
         $this->storage->put($this->previous, $this->uri, $this->options);
     }
     $this->clean();
     $this->initialize();
 }
開發者ID:mychaelstyle,項目名稱:php-utils,代碼行數:14,代碼來源:File.php

示例14: testPut

 /**
  * @covers mychaelstyle\Storage::put
  */
 public function testPut()
 {
     $def1 = $this->dsnMap['Local'];
     $def2 = $this->dsnMap['Local2'];
     $this->object->addProvider($def2['dsn'], $def2['options']);
     $path = DIR_FIXTURES . '/example.txt';
     $expected = file_get_contents($path);
     $this->object->put($path, $this->uri_example, array('permission' => 0644));
     $this->assertLocalWritten($def1['dsn'], $expected, $this->uri_example);
     $this->assertLocalWritten($def2['dsn'], $expected, $this->uri_example);
 }
開發者ID:mychaelstyle,項目名稱:php-utils,代碼行數:14,代碼來源:StorageTest.php

示例15: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $tables = ['maven_faqs', 'maven_tags', 'maven_unique_keys'];
     foreach ($tables as $table) {
         $values = \DB::table($table)->get();
         if (count($values)) {
             $json = json_encode($values);
             \Storage::put('maven/' . $table . '.json', $json);
             $this->info('"' . $table . '" exported!');
         }
     }
 }
開發者ID:sukohi,項目名稱:maven,代碼行數:17,代碼來源:MavenExportCommand.php


注:本文中的Storage::put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。