laravel-filesystem

Laravel How To use another server as file storage

怎甘沉沦 提交于 2020-07-22 06:13:51
问题 I am using Laravel 7.6: I have two Laravel projects in each server (server is normal server. Neither AWS nor Digital Ocean, Just dedicated server). Project1 is in server1. Project2 is in server2. My question is: How can I do CRUD from Project1 To server2? So in Project1 I would like to read, upload, delete, edit files which are in server2. This is my current filesystem configuration. 'disks' => [ 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], 'public' => [ 'driver' =>

Laravel storage returns FileNotFoundException But file exists

久未见 提交于 2020-03-23 07:57:06
问题 I want read file content in laravel 6, the file already exists but laravel return not found exception. This is my logs files directory: /var/www/html/myLaravelLab/storage/logs/laravel-2019-10-14.log $contents = Storage::get(storage_path('logs/laravel-2019-10-14.log')); Laravel return this error: Illuminate\Contracts\Filesystem\FileNotFoundException But file already exists! I want read file contents. Laravel Version: 6.2.0 - PHP Version: 7.2.19 回答1: In config/filesystems.php add new disk logs

Laravel 5: How do you copy a local file to Amazon S3?

久未见 提交于 2019-12-21 16:18:19
问题 I'm writing code in Laravel 5 to periodically backup a MySQL database. My code thus far looks like this: $filename = 'database_backup_'.date('G_a_m_d_y').'.sql'; $destination = storage_path() . '/backups/'; $database = \Config::get('database.connections.mysql.database'); $username = \Config::get('database.connections.mysql.username'); $password = \Config::get('database.connections.mysql.password'); $sql = "mysqldump $database --password=$password --user=$username --single-transaction >

Inserting Empty String or Null Images in Laravel

China☆狼群 提交于 2019-12-13 03:22:11
问题 I can't insert a string or a null value in the database resulting in the following error: SQLSTATE[HY000]: General error: 1364 Field 'paxsafety_video' doesn't have a default value (SQL: insert into pax_safeties ( paxsafety_image , updated_at , created_at ) values (Desert_1543390457.jpg, 2018-11-28 15:34:17, 2018-11-28 15:34:17)) Controller $this->validate($request, [ 'paxsafety_image.*' => 'nullable|image|mimes:jpeg,jpg,png', 'paxsafety_video.*' => 'nullable|mimes:mp4,mov,ogg | max:20000' ]);

Laravel Filesystem/Storage - Local/Public File URLs Not Working

社会主义新天地 提交于 2019-12-10 11:39:37
问题 Aim Hi, I am using laravel for a RESTful API. I would like to return users a URL to an image file. I am currently using local storage, but I have configured an Amazon S3 instance, and synced my images to it. My aim is to seamlessly switch between local storage and s3 by simply changing the first line in my config/filesystems.php: 'default' => 'public', Details I have configured laravel to access both the local disk and S3 via the config/filesystems.php file. As per the laravel instructions I

Should I use CloudFront together as TemporaryUrl for sensitive files in s3

亡梦爱人 提交于 2019-12-08 12:03:57
问题 I have a project where I was storing files in the server itself. The storage is increasing so I need to use a bucket. I thought s3 is the way to go. The issue is the pdf files are sensitive and I don't want to open them to public. I read about a service called CloudFront but then the new feature of Laravel TemporaryUrl as well. So as far as I understand, I shouldn't just use s3, but I should use TemporaryUrl too. Do I need to use CloudFront too? So s3 -> CloudFront -> TemporaryUrl ? Or was

Laravel Impossible to Create Root Directory

南楼画角 提交于 2019-12-07 01:40:45
问题 I've checked out the other posts about this, mine seems to be unique for some reason Essentially what I'm trying to do is store uploaded photos in the public directory for easy access, however when I store them I'm trying to store them in a user specific folder, so /public/photos/$User->id/$filename.jpg Right now I have Dropzone uploading the file, and I've added to my filesystem.php this statement 'public_uploads' => [ 'driver' => 'local', 'root' => public_path(), ], So in theory when I

Laravel 5.3 Storage::put creates a directory with the file name

萝らか妹 提交于 2019-12-06 17:12:30
问题 I'm using Laravel's file storage functionality to save a file: public function dataPost(Request $request) { $fileInForm = 'doc'; if ($request->hasFile($fileInForm)) { $file = $request->file($fileInForm); if ($file->isValid()) { // Filename is hashed filename + part of timestamp $hashedName = hash_file('md5', $file->path()); $timestamp = microtime() * 1000000; $newFilename = $hashedName . $timestamp . '.' . $file->getClientOriginalExtension(); Storage::disk('local')->put($newFilename, $file);

Laravel Impossible to Create Root Directory

眉间皱痕 提交于 2019-12-05 09:46:34
I've checked out the other posts about this, mine seems to be unique for some reason Essentially what I'm trying to do is store uploaded photos in the public directory for easy access, however when I store them I'm trying to store them in a user specific folder, so /public/photos/$User->id/$filename.jpg Right now I have Dropzone uploading the file, and I've added to my filesystem.php this statement 'public_uploads' => [ 'driver' => 'local', 'root' => public_path(), ], So in theory when I access that using Storage::disk('public_uploads') it should retrieve the correct path Here's my controller

Laravel 5.3 Storage::put creates a directory with the file name

岁酱吖の 提交于 2019-12-04 22:49:51
I'm using Laravel's file storage functionality to save a file: public function dataPost(Request $request) { $fileInForm = 'doc'; if ($request->hasFile($fileInForm)) { $file = $request->file($fileInForm); if ($file->isValid()) { // Filename is hashed filename + part of timestamp $hashedName = hash_file('md5', $file->path()); $timestamp = microtime() * 1000000; $newFilename = $hashedName . $timestamp . '.' . $file->getClientOriginalExtension(); Storage::disk('local')->put($newFilename, $file); } } } This does save the file, but inside a directory named the same as the file, for example: storage