1. Go to this page and download the library: Download arshad1114/laravel-dms-disk 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/ */
// ❌ what developers do today — repeated in every service
$response = Http::attach('file', $contents, 'invoice.pdf')
->post('https://dms.internal/upload', ['path' => 'invoices/001.pdf']);
// ✅ with laravel-dms-disk
Storage::disk('dms')->put('invoices/001.pdf', $contents);
Storage::disk('dms')->get('invoices/001.pdf');
Storage::disk('dms')->delete('invoices/001.pdf');
'dms' => [
'driver' => 'dms',
'disk' => 'client', // store on the client disk on the DMS server
],
'disks' => [
// Uses DMS server default disk
'dms' => [
'driver' => 'dms',
'url' => env('DMS_URL'),
'token' => env('DMS_TOKEN'),
],
// Targets the client disk on the DMS server
'dms-client' => [
'driver' => 'dms',
'url' => env('DMS_URL'),
'token' => env('DMS_TOKEN'),
'disk' => 'client',
],
// Points to a completely different DMS service
'dms-archive' => [
'driver' => 'dms',
'url' => env('DMS_ARCHIVE_URL'),
'token' => env('DMS_ARCHIVE_TOKEN'),
],
],
// From a string
Storage::disk('dms')->put('invoices/001.pdf', $pdfContents);
// From an uploaded file in a controller
$request->file('document')->store('documents', 'dms');
// With a custom filename
$request->file('document')->storeAs('documents', 'invoice-001.pdf', 'dms');
// As public visibility
Storage::disk('dms')->put('avatars/user-1.jpg', $imageContents, 'public');
// Get file contents as string
$contents = Storage::disk('dms')->get('invoices/001.pdf');
// Stream download directly to browser
return Storage::disk('dms')->download('invoices/001.pdf');
// Stream with custom filename
return Storage::disk('dms')->download('invoices/001.pdf', 'my-invoice.pdf');
if (Storage::disk('dms')->exists('invoices/001.pdf')) {
// file exists
}
if (Storage::disk('dms')->missing('invoices/001.pdf')) {
// file does not exist
}