ikepu-tp/laravel-file-library

v1.3.0 2024-03-02 04:53 UTC

This package is auto-updated.

Last update: 2024-10-01 00:20:46 UTC


README

这是一个用于Laravel的文件管理库。

如何使用

安装

composer require ikepu-tp/larave-file-library

发布配置等

php artisan vendor:publish --provider="ikepu_tp\FileLibrary\FileLibraryServiceProvider"

路由

注意

{fileId} 表示uuid。

上传文件

默认路由
POST http://your-project.com/file/lib
原始路由
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}

API 文档

FileLibraryController

FileLibraryResource

{
  "fileId": "string",
  "name": "string",
  "url": "string",
  "mime_type": "string",
  "created_at": "string",
  "updated_at": "string"
}

index

显示文件库中的文件列表。

GET http://your-project.com/file/lib
index 示例
{
    "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"
                }
        ]
    }
}

store

上传文件。

POST http://your-project.com/file/lib
store 示例
{
    "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"
        }
    ]
}

show

显示特定文件的详细信息。

GET http://your-project.com/file/lib/{fileId}

update

更新特定文件。

PUT http://your-project.com/file/lib/{fileId}

destroy

删除特定文件。

DELETE http://your-project.com/file/lib/{fileId}

贡献

我们欢迎对该项目的贡献!您可以通过以下方式参与

问题:用于错误报告、功能建议等。

拉取请求:我们鼓励为新功能和错误修复贡献代码。

许可证

LICENSE