PHP code example of globalxtreme / php-storage
1. Go to this page and download the library: Download globalxtreme/php-storage library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
globalxtreme / php-storage example snippets
STORAGE_BASE_URL=<storage-api-gateway> // OPTIONAL
STORAGE_CLIENT_ID=<your-client-id>
STORAGE_CLIENT_SECRET=<your-client-secret>
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;
}
}
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;
bash
composer