hgacreative/storage-manager 问题修复 & 功能扩展

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

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

hgacreative/storage-manager

最新稳定版本:v1.2

Composer 安装命令:

composer require hgacreative/storage-manager

包简介

S3 Storage management

README 文档

README

Used for managing files on S3, via the storage manager facade you can easily upload and delete files as necessary.

This package records data into the database for operation.

Install

composer require hgacreative/storage-manager

Migration

php artisan vendor:publish

Look for Tag: storage-manager-migrations

php artisan migrate

Import

use HgaCreative\StorageManager\Facades\StorageManager;

Upload file

$file = StorageManager::uploadFile($file, $tag);

$tag is the directory you want to place it in, can be something like "users/avatars".

FileUpload model is returned if successful, else null is returned.

Delete File

StorageManager::deleteFile($key)

Deletes the file from the database and from S3

Key

The key is stored within the database, simply grab the one you want and use as such.

An example of a key: directory/sub_directory/image.jpg

Database

The user_id foreign key in the file_uploads table assumes the users table id is defined as such :

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            ...
            ...

If you're using bigIncrements, please change the package's migration foreign user_id type to bigInteger.

Extending FileUpload Model

Create a FileUpload model within your Models folder and simply extend the package's model. You may now extend Its functionality.

 <?php
    
    namespace App\Models;
    use HgaCreative\StorageManager\Models\FileUpload as HgaFileUpload;
    
    class FileUpload extends HgaFileUpload
    {
        //
    }

Routes

Utilise the following routes to upload and delete files from S3:

Method URI Name
POST api/utilities/file-upload api.utilities.file-upload.store
DELETE api/utilities/file-upload api.utilities.file-upload.destroy
  • store takes a file and tag(nullable) to have it uploaded and returned a JSON response.
  • destroy takes a key to delete a file and returns a JSON response

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固