This is a file management library for Laravel.
composer require ikepu-tp/larave-file-library
php artisan vendor:publish --provider="ikepu_tp\FileLibrary\FileLibraryServiceProvider"
HTTP Method | URI | Action | Route Name | Description |
---|---|---|---|---|
GET | /file/lib | index | file-library.index | Display a list of files in the file library. |
GET | /file/lib/create | create | file-library.create | Display a form for uploading a new file. |
POST | /file/lib | store | file-library.store | Upload a file. |
GET | /file/lib/{fileId} | show | file-library.show | Display details of a specific file. |
GET | /file/lib/{fileId}/edit | edit | file-library.edit | Display a form for editing a specific file. |
PUT | /file/lib/{fileId} | update | file-library.update | Update a specific file. |
DELETE | /file/lib/{fileId} | destroy | file-library.destroy | Delete a specific file. |
Note
{fileId}
means uuid.
POST http://your-project.com/file/lib
Key | Type | Accepted Values | Required |
---|---|---|---|
files | Array<int, File> | Y | |
names | Array<int, string> | max length: 250 | Y |
class FileController extends Controller
{
public function store(Request $request)
{
$guard = config("file-library.guard");
$files = \ikepu_tp\FileLibrary\app\Services\FileLibraryService::upload(
$guard,
$request->file("files", []),
$request->input("names", [])
);
return back()->with("status", "File uploaded.");
}
}
PUT http://your-project.com/file/lib/{fileId}
Key | Type | Accepted Values | Required |
---|---|---|---|
name | string | max length: 250 | Y |
{
"fileId": "string",
"name": "string",
"url": "string",
"mime_type": "string",
"created_at": "string",
"updated_at": "string"
}
Display a list of files in the file library.
GET http://your-project.com/file/lib
{
"status":{
"result":true,
"code":200,
},
"payloads":{
"meta": {
"currentPage": 1,
"lastPage": 1,
"length": 1,
"getLength": 0,
"per":1,
},
"items":[
{
"fileId": "uuid",
"name": "file name",
"url": "http://your-project.com/file/lib/uuid",
"mime_type": "application/json",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
]
}
}
Upload a file.
POST http://your-project.com/file/lib
{
"files": [
"FILE BINARY",
],
"names":[
"file name",
]
}
{
"status":{
"result":true,
"code":201,
},
"payloads": [
{
"fileId": "uuid",
"name": "file name",
"url": "http://your-project.com/file/lib/uuid",
"mime_type": "application/json",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
]
}
Display details of a specific file.
GET http://your-project.com/file/lib/{fileId}
Update a specific file.
PUT http://your-project.com/file/lib/{fileId}
Delete a specific file.
DELETE http://your-project.com/file/lib/{fileId}
We welcome contributions to the project! You can get involved through the following ways:
Issue: Use for bug reports, feature suggestions, and more.
Pull Requests: We encourage code contributions for new features and bug fixes.
See LICENSE.