Source: tharindums59.medium.com

Upload Image To Google Cloud Storage
Google Cloud Storage is an object storage in the cloud. gcs’ => [ ‘driver’ => ‘gcs’, ‘project_id’ => env(‘GOOGLE_CLOUD_PROJECT_ID’, ‘your-project-id’), ‘key_file’ => env(‘GOOGLE_CLOUD_KEY_FILE’, null), ‘bucket’ => env(‘GOOGLE_CLOUD_STORAGE_BUCKET’, ‘your-bucket’), ‘path_prefix’ => env(‘GOOGLE_CLOUD_STORAGE_PATH_PREFIX’, null), // optional There are five environment variables you have to set,You can add this as a array also like below , ‘key_file’ => [ ‘type’ => env(‘GOOGLE_CLOUD_ACCOUNT_TYPE’), ‘private_key_id’ => env(‘GOOGLE_CLOUD_PRIVATE_KEY_ID’), ‘private_key’ => env(‘GOOGLE_CLOUD_PRIVATE_KEY’), ‘client_email’ => env(‘GOOGLE_CLOUD_CLIENT_EMAIL’), ‘client_id’ => env(‘GOOGLE_CLOUD_CLIENT_ID’), ‘auth_uri’ => env(‘GOOGLE_CLOUD_AUTH_URI’), ‘token_uri’ => env(‘GOOGLE_CLOUD_TOKEN_URI’), ‘auth_provider_x509_cert_url’ => env(‘GOOGLE_CLOUD_AUTH_PROVIDER_CERT_URL’), ], Example for upload image to the Google Cloud Storage,Create a controller Php artisan make:controller UserProfileController create a method named update which stores the uploaded image file to GCS namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; class UserProfileController extends Controller

public function updateProfile(Request $request) $disk = Storage::disk(‘gcs’); // create a file $profile = $request->file(‘user_profile’); $disk->put(‘profile’, $profile); }
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners