Https://neoacevedo.gumroad.com/l/yii2-storage

Yii2 component for storage management in cloud. It supports AWS S3, Azure Blob Storage, Google Cloud Storage but also it can be used for local storage.

#yii2 #php #dev #component #extension #azureblobstorage #azurefilestorage #googlecloudstorage #s3 #aws

Yii2 Storage

Yii2 Storage A complete extension for file storage management in Yii2 that supports multiple cloud and local storage providers.Features ✅ Multiple providers: Amazon S3, Azure Blob Storage, Google Cloud Storage and local storage ✅ File validation: Control of allowed file extensions and types ✅ Flexible configuration: Support for path prefixes and custom configurations ✅ Easy integration: Compatible with Yii2 forms and models ✅ URL management: Automatic generation of public URLs for files Tags: #storage #component #upload #file #extension #aws #azure #google #yii2Demo. File upload form is in the index.InstallationThis extension is distributed as a ZIP file that must be manually extracted.This documentation asumes the user is familiar with AWS S3, Azure Blob Storage and/or Google Cloud Storage service(s).Installation steps: Download the yii2-storage component ZIP file Extract to a directory of your choice within the project:components/neoacevedo/yii2-storage/ Configure repository in your composer.json project:"repositories": [ { "type": "composer", "url": "https://asset-packagist.org" }, { "type": "path", "name": "neoacevedo/yii2-storage", "url": "components/neoacevedo/yii2-storage" } ] Regenerate autoloader:Option 1: Direct installation composer require neoacevedo/yii2-storage Option 2: Add to the require section of your composer.json project { "require": { "neoacevedo/yii2-storage": "dev-main" } } Then run:composer update ConfigurationOnce the extension is installed, configure the storage component in your Yii2 application configuration file (config/web.php or common/config/main.php):Amazon S3'components' => [ 'storage' => [ 'class' => 'neoacevedo\yii2\storage\S3Storage', 'accessKey' => 'YOUR_IAM_ACCESS_KEY', 'secretAccessKey' => 'YOUR_IAM_SECRET_ACCESS_KEY', 'bucket' => 'your-bucket-name', 'region' => 'us-east-1', // AWS Region 'directory' => 'uploads/', // Directory within the bucket (optional) 'acl' => 'public-read', // File ACL (optional) 'storageClass' => 'STANDARD', // Storage class (optional) 'presignedUrl' => true, // Signed URLs (optional) 'presignedUrlExpiration' => '+1 hour', // Expiration time (optional) 'allowedExtensions' => 'pdf,jpg,jpeg,gif,png,bmp,doc,docx,xls,xlsx' ], ], Azure Blob Storage'components' => [ 'storage' => [ 'class' => 'neoacevedo\yii2\storage\AzureBlobStorage', 'accountName' => 'YOUR_STORAGE_ACCOUNT_NAME', 'accountKey' => 'YOUR_STORAGE_ACCOUNT_KEY', 'container' => 'your-container-name', 'directory' => 'uploads/', // Directory within the container (optional) 'cdn' => 'https://your-cdn.azureedge.net', // CDN URL (optional) 'hierarchicalNamespace' => false, // true for Data Lake Gen2 (optional) 'allowedExtensions' => 'pdf,jpg,jpeg,gif,png,bmp,doc,docx,xls,xlsx' ], ], Google Cloud Storage'components' => [ 'storage' => [ 'class' => 'neoacevedo\yii2\storage\GoogleCloudStorage', 'projectId' => 'YOUR_PROJECT_ID', 'bucket' => 'your-bucket-name', 'keyFileContent' => file_get_contents('/path/to/service-account-key.json'), // JSON file content 'directory' => 'uploads/', // Directory within the bucket (optional) 'cdn' => 'https://your-cdn.googleusercontent.com', // CDN URL (optional) 'presignedUrl' => true, // Signed URLs (optional) 'presignedUrlExpiration' => 3600, // Expiration time in seconds (optional) 'allowedExtensions' => 'pdf,jpg,jpeg,gif,png,bmp,doc,docx,xls,xlsx' ], ], Local Storage'components' => [ 'storage' => [ 'class' => 'neoacevedo\yii2\storage\LocalStorage', 'directory' => '@webroot/uploads/', // Physical storage directory 'cdn' => 'https://your-cdn.com', // CDN URL (optional) 'allowedExtensions' => 'pdf,jpg,jpeg,gif,png,bmp,doc,docx,xls,xlsx' ], ], UsageBasic Usage with Component<?php // In your controller use yii\web\UploadedFile; public function actionUpload() { $fileManager = Yii::$app->storage->getFileManager(); if (Yii::$app->request->isPost) { $fileManager->uploadedFile = UploadedFile::getInstance($fileManager, 'uploadedFile'); if ($fileManager->validate() && Yii::$app->storage->save($fileManager)) { // File uploaded successfully $fileUrl = Yii::$app->storage->getUrl($fileManager->fileName); Yii::$app->session->setFlash('success', 'File uploaded successfully: ' . $fileUrl); } else { Yii::$app->session->setFlash('error', 'Error uploading file.'); } } return $this->render('upload', ['fileManager' => $fileManager]); } Direct Usage without Component<?php use neoacevedo\yii2\storage\S3Storage; use yii\web\UploadedFile; public function actionUpload() { $storage = new S3Storage([ 'accessKey' => 'YOUR_IAM_ACCESS_KEY', 'secretAccessKey' => 'YOUR_IAM_SECRET_ACCESS_KEY', 'bucket' => 'your-bucket-name', 'region' => 'us-east-1', 'directory' => 'uploads/', 'allowedExtensions' => 'pdf,jpg,jpeg,gif,png,bmp' ]); $fileManager = $storage->getFileManager(); $fileManager->uploadedFile = UploadedFile::getInstance($fileManager, 'uploadedFile'); if ($storage->save($fileManager)) { return $storage->getUrl($fileManager->fileName); } return false; } Form IntegrationIn the Controller:public function actionCreate() { $model = new YourModel(); $fileManager = Yii::$app->storage->getFileManager(); if ($model->load(Yii::$app->request->post())) { $fileManager->uploadedFile = UploadedFile::getInstance($fileManager, 'uploadedFile'); if ($fileManager->validate() && Yii::$app->storage->save($fileManager)) { $model->file_path = $fileManager->fileName; if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } } return $this->render('create', [ 'model' => $model, 'fileManager' => $fileManager ]); } In the View:<?php use yii\widgets\ActiveForm; $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?= $form->field($model, 'name')->textInput() ?> <?= $form->field($fileManager, 'uploadedFile')->fileInput([ 'accept' => 'image/*,.pdf,.doc,.docx', 'class' => 'form-control' ]) ?> <div class="form-group"> <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?> </div> <?php ActiveForm::end(); ?> Available Methods// Get file manager $fileManager = Yii::$app->storage->getFileManager(); // Save file $success = Yii::$app->storage->save($fileManager); // Get file URL $url = Yii::$app->storage->getUrl('filename.jpg'); // Delete file $deleted = Yii::$app->storage->delete('filename.jpg'); // List of files/directories in the bucket. Optional: directory name ending with '/' to list its contents. $files = Yii::$app->storage->list(); Advanced Configuration ExamplesMultiple Configuration'components' => [ 'storageImages' => [ 'class' => 'neoacevedo\yii2\storage\S3Storage', 'accessKey' => 'YOUR_ACCESS_KEY', 'secretAccessKey' => 'YOUR_SECRET_KEY', 'bucket' => 'images-bucket', 'region' => 'us-east-1', 'directory' => 'images/', 'allowedExtensions' => 'jpg,jpeg,gif,png,bmp' ], 'storageDocuments' => [ 'class' => 'neoacevedo\yii2\storage\S3Storage', 'accessKey' => 'YOUR_ACCESS_KEY', 'secretAccessKey' => 'YOUR_SECRET_KEY', 'bucket' => 'documents-bucket', 'region' => 'us-east-1', 'directory' => 'documents/', 'allowedExtensions' => 'pdf,doc,docx,xls,xlsx' ], ], LicenseThis project is licensed under the GPLv3 License. See LICENSE file for more details.SupportIf you encounter any issues or have questions, please send an email to [email protected].

Gumroad

https://neoacevedo.gumroad.com/l/joomla-cloudstorage-filesystem

I've made this Joomla filesystem plugin for storage management in cloud. It supports Azure Blob Storage, Azure File Storage and Google Cloud Storage.

Originally I developed more than 6 year ago in separated plugins this storage filesystem plugin. Now, I've joined all these in one only plugin.

#joomla #plugin #cloudstorage #filesystem #azurefilestorage
#azureblobstorage #googlecloudstorage

Joomla Cloud Storage Filesystem

FileSystem CloudStorage Plugin for JoomlaThis plugin allows you to use Azure Blob Storage, Azure File Storage, and Google Cloud Storage as storage providers in Joomla's Media Manager.Features Support for Azure Blob Storage Support for Azure File Storage Support for Google Cloud Storage Multiple storage configurations Full Media Manager integration Intuitive configuration interface Installation Install the plugin via the Joomla Extension Manager Enable the plugin in System > Plugins > FileSystem - Cloud Storage ConfigurationAzure Blob Storage Get the connection string from the Azure portal Create a container in Azure Blob Storage In the plugin settings: Type: Azure Blob Storage Name: Descriptive display name Container: Container name Connection String: Azure connection string Azure File Storage Get the connection string from the Azure portal Create a file share in Azure File Storage In the plugin settings: Type: Azure File Storage Name: Descriptive display name Container: Container name Connection String: Azure connection string Google Cloud Storage Create a project in the Google Cloud Console Enable the Cloud Storage API Create a service account and download the credentials JSON Create a bucket in Google Cloud Storage In the plugin settings: Type: Google Cloud Storage Name: Descriptive display name Container/Bucket: Bucket name Project ID: Google Cloud project ID Credentials JSON: Full contents of the credentials JSON file DependenciesThis plugin uses direct HTTP requests to the Azure and Google Cloud REST APIs, so it doesn't require any additional SDKs. It only requires: Joomla 6.0+ PHP 8.2+ OpenSSL extension (for Google Cloud Storage) cURL extension LicenseGNU General Public License version 3 or later

Gumroad

Good names save lives!

On #GoogleCloudStorage, the field in which you're meant to list which _request_ headers are allowed by your bucket's #CORS configuration is named... "responseHeader". 🤨

https://cloud.google.com/storage/docs/cross-origin#cors-components

Why?! If anything, that field should have been named "requestHeader"!

Cross-origin resource sharing (CORS)  |  Cloud Storage  |  Google Cloud

Google Cloud
I am saving my peertube videos in GCS ( #GoogleCloudStorage ) however my VM is running in Digital Ocean. I explored DOS ( #DigitalOceanSpaces ) before, I may try and move my storage of peertube to DOS
Hmm… is there some special magic spell I have to perform in order for bucket label updates via the #golang SDK for #GoogleCloudStorage to work? The Update call returns without error but the labels are not updated (or set for that matter)…
Pfizer : quand une "mauvaise configuration" d'un bucket de Google Cloud Storage crée une aspiration de données ! | SOSOrdi.net

SOSOrdi.net

このサーバで #Mastodon が一通り使えるようになりました。

構築:
- #GoogleCloudPlatform のus-central1リージョンus-central1-aゾーン上に構築
- machine-typesはf1-micro・g1-small・n1-standard-1のいずれか https://cloud.google.com/compute/docs/machine-types
- `dd if=/dev/zero of=/swapfile bs=1M count=4096`でスワップファイル約4GBを作成
- #CentOS7 - #ShieldedVM - 標準の永続ディスク 30 GB
- #GoogleCloudStorage#S3 互換バケット)使用
- #GoogleCloudSql#PostgreSQL 9.6で使用
- #Redis はVMインスタンス内
- ドメインは #GoogleDomain
- メールサーバは #Mailgun
- #ElasticSearch 有効

Machine Types  |  Compute Engine Documentation  |  Google Cloud