本文整理汇总了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()];
}
}
示例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()));
}
示例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
// ],
// ]
// );
}
示例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);
}
示例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']));
}
示例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);
}
示例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]);
}
}
示例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);
}
示例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');
}
示例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]);
}
示例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;
}
示例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");
}
示例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();
}
示例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);
}
示例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!');
}
}
}