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/ */
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(new GXStorageForm(
file: $request->file('file'), // Required: Ambil langsung dari parameter request
path: "images/attachments/", // Required: Isi dengan path dimana kamu mau simpan file ini. pastikan path sudah terdaftar dan locked
mimeType: "image/jpeg", // Optional: Jika bisa langsung kirim juga untuk meringankan beban public storage
savedUntil: 10, // Optional: Isi jika ingin menghapus setelah disimpan selama beberapa hari
title: "", // Optional: Isi jika perlu title
ownerId: "", // Optional: Isi jika ingin menentukan pemilik file dan agar saat folder di lock dengan password, pemilik file tidak perlu memasukan password
ownerType: "", // Optional: (employee, customer). Hanaya untuk identifikasi id yang dikirim adalah employee atau customer
createdBy: "", // Optional: Isi jika kamu perlu menyimpan siapa yang upload file tersebut
createdByName: "", // Optional: Isi jika kamu perlu menyimpan siapa yang upload file tersebut
reference: "", // Optional: Ini berfungsi agar saat file dihapus di public storage, server / pemilik file bisa tahu tabel mana yang harus dihapus link nya
referenceType: "", // Optional: Ini berfungsi agar saat file dihapus di public storage, server / pemilik file bisa tahu tabel mana yang harus dihapus link nya
external: true, // Optional: Isi jika ingin menyimpan dan mengkases link dengan url / domain public (gunakan jika ingin mengirim link ke customer)
));
// Store from file path
$store = GXStorage::store(new GXStorageForm(
file: storage_path('path/to/filename'), // Required: Ambil langsung dari parameter request
path: "images/attachments/", // Required: Isi dengan path dimana kamu mau simpan file ini. pastikan path sudah terdaftar dan locked
mimeType: "image/jpeg", // Optional: Jika bisa langsung kirim juga untuk meringankan beban public storage
savedUntil: 10, // Optional: Isi jika ingin menghapus setelah disimpan selama beberapa hari
title: "", // Optional: Isi jika perlu title
ownerId: "", // Optional: Isi jika ingin menentukan pemilik file dan agar saat folder di lock dengan password, pemilik file tidak perlu memasukan password
ownerType: "", // Optional: (employee, customer). Hanaya untuk identifikasi id yang dikirim adalah employee atau customer
createdBy: "", // Optional: Isi jika kamu perlu menyimpan siapa yang upload file tersebut
createdByName: "", // Optional: Isi jika kamu perlu menyimpan siapa yang upload file tersebut
reference: "", // Optional: Ini berfungsi agar saat file dihapus di public storage, server / pemilik file bisa tahu tabel mana yang harus dihapus link nya
referenceType: "", // Optional: Ini berfungsi agar saat file dihapus di public storage, server / pemilik file bisa tahu tabel mana yang harus dihapus link nya
external: true, // Optional: Isi jika ingin menyimpan dan mengkases link dengan url / domain public (gunakan jika ingin mengirim link ke customer)
));
// Copy file to another service
$copy = GXStorage::copyToAnotherService(new GXStorageMoveCopyToAnotherServiceForm(
file: "https://dev.storage.globalxtreme-gateway.net/link/path/filename", // Required: full path (link) yang ingin di copy
toClientId: 111111111111, // Required: Client id tempat tujuan file di copy
toPath: "photos/attachments/" // Required: Path tempat file ingin di copy
));
// Move file to another service
$move = GXStorage::moveToAnotherService(new GXStorageMoveCopyToAnotherServiceForm(
file: "https://dev.storage.globalxtreme-gateway.net/link/path/filename", // Required: full path (link) yang ingin di copy
toClientId: 111111111111, // Required: Client id tempat tujuan file di copy
toPath: "photos/attachments/" // Required: Path tempat file ingin di copy
));
// Copy file from another service
$copy = GXStorage::copyFromAnotherService(new GXStorageMoveCopyFromAnotherServiceForm(
file: "https://dev.storage.globalxtreme-gateway.net/link/path/filename", // Required: full path (link) yang ingin di copy
fromClientId: 111111111111, // Required: Client id tempat asal file di copy
toPath: "photos/attachments/" // Required: Path tempat file ingin di copy
));
// Move file from another service
$move = GXStorage::moveFromAnotherService(new GXStorageMoveCopyFromAnotherServiceForm(
file: "https://dev.storage.globalxtreme-gateway.net/link/path/filename", // Required: full path (link) yang ingin di copy
fromClientId: 111111111111, // Required: Client id tempat asal file di copy
toPath: "photos/attachments/" // Required: Path tempat file ingin di copy
));
// Form untuk generate file zip menggunakan public storage links
$zipForm = new GXStorageZIPForm(
path: 'attachments/zips/', // Required: Isi dengan path tempat file zip ingin disimpan
filename: 'contoh-file.zip', // Required: Isi dengan nama file zip yang dinginkan, ini berguna saat download file
title: "", // Optional: Isi jika perlu title
ownerId: "", // Optional: Isi jika ingin menentukan pemilik file dan agar saat folder di lock dengan password, pemilik file tidak perlu memasukan password
ownerType: "", // Optional: (employee, customer). Hanaya untuk identifikasi id yang dikirim adalah employee atau customer
reference: "", // Optional: Ini berfungsi agar saat file dihapus di public storage, server / pemilik file bisa tahu tabel mana yang harus dihapus link nya
referenceType: "", // Optional: Ini berfungsi agar saat file dihapus di public storage, server / pemilik file bisa tahu tabel mana yang harus dihapus link nya
createdBy: "", // Optional: Isi jika kamu perlu menyimpan siapa yang upload file tersebut
createdByName: "", // Optional: Isi jika kamu perlu menyimpan siapa yang upload file tersebut
savedUntil: 10, // Optional: Isi jika ingin menghapus setelah disimpan selama beberapa hari
external: true, // Optional: Isi jika ingin menyimpan dan mengkases link dengan url / domain public (gunakan jika ingin mengirim link ke customer)
);
// Daftarkan file-file yang ingin kamu masukan ke dalam zip. (MINIMAL 1 FILE)
$zipForm->setFile(
filename: 'INVOICE-1111111.pdf', // Required: Isi dengan nama file yang ingin kamu simpan nanti di zip
link: 'https://dev.storage.globalxtreme-gateway.net/link/path/filename', // Required: Isi dengan full link yang kamu dapatkan dari public storage (PASTIKAN LINK NYA BENAR)
);
$zipForm->setFile(
filename: 'INVOICE-22222222.pdf', // Required: Isi dengan nama file yang ingin kamu simpan nanti di zip
link: 'https://dev.storage.globalxtreme-gateway.net/link/path/filename', // Required: Isi dengan full link yang kamu dapatkan dari public storage (PASTIKAN LINK NYA BENAR)
);
$zip = GXStorage::generateZIP($zipForm)
// 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;
// Saved Until
$store->savedUntil;
// 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 from file path
$store = GXStorage::store(new GXStorageForm(
file: $_FILES['file']['tmp_name'], // Required: Ambil langsung dari parameter request
path: "images/attachments/", // Required: Isi dengan path dimana kamu mau simpan file ini. pastikan path sudah terdaftar dan locked
originalName: $_FILES['file']['original_name'], // Optional: Isi jika perlu menyimpan original name juga
mimeType: "image/jpeg", // Optional: Jika bisa langsung kirim juga untuk meringankan beban public storage
savedUntil: 10, // Optional: Isi jika ingin menghapus setelah disimpan selama beberapa hari
title: "", // Optional: Isi jika perlu title
ownerId: "", // Optional: Isi jika ingin menentukan pemilik file dan agar saat folder di lock dengan password, pemilik file tidak perlu memasukan password
ownerType: "", // Optional: (employee, customer). Hanaya untuk identifikasi id yang dikirim adalah employee atau customer
createdBy: "", // Optional: Isi jika kamu perlu menyimpan siapa yang upload file tersebut
createdByName: "", // Optional: Isi jika kamu perlu menyimpan siapa yang upload file tersebut
));
// 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;
// Saved Until
$store->savedUntil;
// Delete file
$delete = GXStorage::delete("inventories/pdf/4z0Zw5FUCrWfC9oQiian1686389620255618000.xlsx");
// 200
$delete->status;
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.