zotyo/u-filer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zotyo/u-filer

Composer 安装命令:

composer require zotyo/u-filer

包简介

Manage file uploads

关键字:

README 文档

README

The package offers you a more convenient way to manage file uploads in Laravel.

Instead of reinventing the wheel at each file-upload managing your uploaded files will be easy and consistent.

  • Upload file with unique name, without concurrency problems.
  • Store client-side informations of uploaded files in FileDescriptors.
  • File object for ease of managing files in your application.
  • Helper trait for your Eloquent models to easily create accessors/mutators.
  • User friendly replacement of regular <input type="file"/>

By default the package is configured to upload images but you can use for any mime type.

Installation

composer require "zotyo/u-filer"

After downloading the package, add PackageServiceProvider to the providers array of your config/app.php

Zotyo\uFiler\PackageServiceProvider::class

Finally you should publish config of the package with some examples.

php artisan vendor:publish --provider="Zotyo\uFiler\PackageServiceProvider"

Usage

Several components come with the package to reduce the effort of implementing a proper file-upload.

File-input

You can publish a file-input.vue component into your /resources/assets/js/components folder. Modify the component so it would fit into your design.

<div class="form-group">
    <label for="avatar">Avatar</label>
    <file-input id="avatar" v-model="user.avatar"></file-input>
</div>

The vue-component uploads the file to a specific endpoint.

Note: You can avoid VueJS at all if you want so.

Endpoint(Route+Controller)

The package provides an Http endpoint for uploading files. You can disable the endpoint int the configuration file. If you would like to define your custom endpoint, you can still reuse UploadControllerTrait.

Method    | URI               | Name          | Action
POST      | upload            | upload        | Zotyo\uFiler\Http\UploadController@upload

Eloquent

The HasFile trait provides methods so you can easily create accessors/mutators in you model. In the following example User's avatar is a file.

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Zotyo\uFiler\HasFile;

class User extends Authenticatable
{

    use HasFile;
    protected $fillable = ['avatar'];
    protected $appends  = ['avatar'];

    public function getAvatarAttribute()
    {
        return $this->getFile('avatar');
    }

    public function setAvatarAttribute($value)
    {
        $this->setFile('avatar', $value);
    }
}

Validation

Don't forget to validate files when submitting your entities. The package provides the verify-file-by-token validation rule to avoid hijacking of files.

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UserFormRequest extends FormRequest
{
    public function rules()
    {
        return [
            'avatar' => 'required|verify-file-by-token'
        ];
    }
}

zotyo/u-filer 适用场景与选型建议

zotyo/u-filer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 51 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 10 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「file」 「upload」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 zotyo/u-filer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 zotyo/u-filer 我们能提供哪些服务?
定制开发 / 二次开发

基于 zotyo/u-filer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 51
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-17