Posts

Showing posts with the label Google Cloud Storage

Integrate Laravel with Google Cloud Storage for file upload, listing, downloading, and deleting

Image
To integrate Laravel with Google Cloud Storage for file upload, listing, downloading, and deleting, you can follow these steps: 1. Install Required Packages First, install the Google Cloud Storage package for Laravel. You can use google/cloud-storage and laravel/filesystem to handle cloud storage integration. Run the following command in your Laravel project: composer require google/cloud-storage Then, install the league/flysystem-google-cloud-storage package, which provides an adapter for Laravel’s filesystem: composer require league/flysystem-google-cloud-storage 2. Configure Google Cloud Storage Next, configure your Google Cloud Storage credentials. Create a Google Cloud Storage Bucket if you don’t have one already. Generate a Service Account Key from Google Cloud Console: Go to the Google Cloud Console . Navigate to IAM & Admin > Service Accounts . Create a new service account and assign it the Storage Object Admin role. Download the generated JSON key file. Store th...

Google Cloud Storage + Python Flask - File Upload, Download, List, and Delete Example

Image
Here’s an example of how to use Google Cloud Storage with Python Flask for file upload, download, list, and delete operations. You’ll need to install the google-cloud-storage library and set up your Google Cloud project with the necessary credentials. Prerequisites: Install the required packages: pip install Flask google-cloud- storage Set up your Google Cloud project and service account credentials. Download the JSON credentials file and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of the file: export GOOGLE_APPLICATION_CREDENTIALS = "/path/to/your-service-account-file.json" Flask Application with Google Cloud Storage Integration from flask import Flask, request, jsonify, send_file from google.cloud import storage import os app = Flask(__name__) # Initialize Google Cloud Storage client storage_client = storage.Client() # Your Google Cloud bucket name BUCKET_NAME = 'your-bucket-name' # Upload a file to Google Cloud Storage @a...

Google Cloud Storage (GCS) + GoLang - File Upload, Download, List, and Delete Example

Image
To set up and use Google Cloud Storage in GoLang for uploading, listing, downloading, and deleting files, follow these steps: 1. Set Up Google Cloud Project Create a Google Cloud Project : Go to the Google Cloud Console . Create a new project or use an existing one. Enable Google Cloud Storage API : Navigate to APIs & Services > Library in the console. Search for "Cloud Storage" and enable it for your project. Create a Storage Bucket : Navigate to Storage > Browser in the console. Click Create Bucket , give it a unique name, choose a location, and configure other settings. Set Up a Service Account : Go to IAM & Admin > Service Accounts . Create a new service account with the Storage Admin role. Generate a key (JSON) and download it to your local machine. 2. Install the GoLang Google Cloud Storage Library Install the official library using go get : go get cloud.google. com / go /storage 3. Configure Authentication Set the GOOGLE_APPLICATION_CREDENTIALS e...

Google Cloud Storage (GCS) + Django - File Upload, Download, List, and Delete Example

Image
To integrate Google Cloud Storage (GCS) with a Django application for file upload, download, list, and delete operations , follow these steps: 1. Set Up Google Cloud Storage Create a Google Cloud Project : Visit the Google Cloud Console and create a new project or use an existing one. Enable the Cloud Storage API : Navigate to APIs & Services > Library , search for "Cloud Storage," and enable it. Create a GCS Bucket : Go to Storage > Browser in the console. Click Create Bucket , choose a globally unique name, configure settings, and create it. Set Up a Service Account : Go to IAM & Admin > Service Accounts , create a service account, and assign the Storage Admin role. Generate a key (JSON) for the service account and download it to your local machine. 2. Configure Django for GCS Install Required Libraries : Install the Google Cloud Storage and Django libraries: pip install google-cloud- storage django-storages Set Up the Django Storage Backend : Add th...

Google Cloud Storage + Spring Boot - File Upload, Download, and Delete

Image
In this section, we will learn  how to  create a simple spring boot application to perform different file operations such as upload, download, list, and delete files from the Google Cloud Storage. 1.  A little bit of Background Google Cloud Storage Cloud Storage is a managed service for storing unstructured data. Store any amount of data and retrieve it as often as you like. More Info - click here! Spring Boot Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can "just run".  More Info - click here! 2. Create a GCP Project First, Sign into the Google console at  https://console.cloud.google.com . You can create a new project by first selecting the project dropdown in the top left and selecting " New Project ". Next, specify your GCP  Project name  and  Project ID . Then  Click on the " CREATE " button. Copy " Project ID " and keep it for future purposes. 3. Create a Google Cloud Storage bucke...