globalxtreme / php-storage
GlobalXtreme Storage Package for PHP Language
1.0.17
2024-05-11 04:39 UTC
Requires
- php: 7.*|8.*
- guzzlehttp/guzzle: ^5.0|^6.0|^7.0|^7.5|^7.8
- illuminate/support: ^5.0|^6.0.|^7.0.|^8.0.|^9.0|^10.0|^11.0
- symfony/http-foundation: ^v5.0|v6.0.*|v6.1.*|v6.2.*|v7.0.*|v7.1.*
- vlucas/phpdotenv: ^4.0|5.*
README
Install with composer
To install with Composer, simply require the latest version of this package.
composer require globalxtreme/php-storage
Using
- Setup .env.
STORAGE_BASE_URL=<storage-api-gateway> // OPTIONAL STORAGE_CLIENT_ID=<your-client-id> STORAGE_CLIENT_SECRET=<your-client-secret>
- In laravel.
use App\Http\Controllers\Controller; use App\Http\Request; use GlobalXtreme\PHPStorage\GXStorage; class CustomController extends Controller { public function testing(Request $request) { // Store from parameter request $store = GXStorage::store("path/to", $request->file('file'), "Title"); // Store from file path $store = GXStorage::store("path/to", file_get_contents(storage_path('path/to/filename')), "Title"); // 200 $store->status; // Success $store->message; // inventories/pdf/4z0Zw5FUCrWfC9oQiian1686389620255618000.xlsx $store->path; // https://storage.globalxtreme-gateway.net/storages/inventories/pdf/4z0Zw5FUCrWfC9oQiian1686389620255618000.xlsx $store->fullPath; // Title $store->title; // Delete file $delete = GXStorage::delete("inventories/pdf/4z0Zw5FUCrWfC9oQiian1686389620255618000.xlsx"); // 200 $delete->status; } }
- In PHP Native
include("vendor/autoload.php") use GlobalXtreme\PHPStorage\GXStorage; // Load .env file $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->safeLoad(); $store = GXStorage::store("path/to", file_get_contents($_FILES['file']['tmp_name']), "Title"); // 200 $store->status; // Success $store->message; // inventories/pdf/4z0Zw5FUCrWfC9oQiian1686389620255618000.xlsx $store->path; // https://storage.globalxtreme-gateway.net/storages/inventories/pdf/4z0Zw5FUCrWfC9oQiian1686389620255618000.xlsx $store->fullPath; // Title $store->title; // Delete file $delete = GXStorage::delete("inventories/pdf/4z0Zw5FUCrWfC9oQiian1686389620255618000.xlsx"); // 200 $delete->status;