多用户文件管理器-FileGator

简介

logo
FileGator 是一个免费的、开源的、自托管的 Web 应用程序,用于管理文件和文件夹。 您可以管理本地存储库文件夹(在服务器的硬盘驱动器上)中的文件,也可以连接到其他存储适配器。 FileGator 具有多用户支持,因此您可以让管理员和其他用户使用不同的访问权限、角色和主文件夹管理文件。 支持所有基本文件操作:复制、移动、重命名、创建、删除、压缩、解压缩、下载、上传。 如果允许,用户可以一次下载多个文件或文件夹。 文件上传支持拖放、进度条、暂停和恢复。Upload 是分块的,因此无论您的服务器配置如何,您都应该能够上传大文件。

特点和目标

  • 多个存储适配器(Local、FTP、Amazon S3、Dropbox、DO Spaces、Azure Blob 和许多其他通过 Flysystem 的适配器)
  • 具有角色和权限的多个身份验证适配器(将用户存储在 json 文件、数据库中或使用 WordPress)
  • 多个会话适配器(Native File、Pdo、Redis、MongoDB、Memcached 等通过 Symfony)
  • 单页前端(使用 Vuejs、Bulma 和 Buefy 构建)
  • 分块上传(使用 Resumable.js 构建)
  • Zip 和批量下载支持
  • 高度可扩展、解耦和测试的代码
  • 无需数据库

应用场景

  • 团队内部分享文件和资料
  • 学生提交作业
  • 工作人员上传现场数据、文档和图片
  • 作为云备份工具
  • 管理CDN
  • 替代FTP/SFTP服务
  • 管理第三方云存储
描述文字 描述文字

官网


docker测试部署

$ docker run -p 8080:8080 -d filegator/filegator
visit: http://<IP>:8080 login as admin/admin123

docker compose部署

准备配置文件

cat configuration.php

<?php

return [
    'public_path' => APP_PUBLIC_PATH,
    'public_dir' => APP_PUBLIC_DIR,
    'overwrite_on_upload' => false,
    'timezone' => 'UTC', // https://www.php.net/manual/en/timezones.php
    'download_inline' => ['pdf'], // download inline in the browser, array of extensions, use * for all
    'lockout_attempts' => 5, // max failed login attempts before ip lockout
    'lockout_timeout' => 15, // ip lockout timeout in seconds

    'frontend_config' => [
        'app_name' => 'FileGator',
        'app_version' => APP_VERSION,
        'language' => 'chinese', //主要是要修改语言
        'logo' => 'https://filegator.io/filegator_logo.svg',
        'upload_max_size' => 100 * 1024 * 1024, // 100MB
        'upload_chunk_size' => 1 * 1024 * 1024, // 1MB
        'upload_simultaneous' => 3,
        'default_archive_name' => 'archive.zip',
        'editable' => ['.txt', '.css', '.js', '.ts', '.html', '.php', '.json', '.md'],
        'date_format' => 'YY/MM/DD hh:mm:ss', // see: https://momentjs.com/docs/#/displaying/format/
        'guest_redirection' => '', // useful for external auth adapters
        'search_simultaneous' => 5,
        'filter_entries' => [],
    ],

    'services' => [
        'Filegator\Services\Logger\LoggerInterface' => [
            'handler' => '\Filegator\Services\Logger\Adapters\MonoLogger',
            'config' => [
                'monolog_handlers' => [
                    function () {
                        return new \Monolog\Handler\StreamHandler(
                            __DIR__.'/private/logs/app.log',
                            \Monolog\Logger::DEBUG
                        );
                    },
                ],
            ],
        ],
        'Filegator\Services\Session\SessionStorageInterface' => [
            'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
            'config' => [
                'handler' => function () {
                    $save_path = null; // use default system path
                    //$save_path = __DIR__.'/private/sessions';
                    $handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler($save_path);

                    return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([
                            "cookie_samesite" => "Lax",
                            "cookie_secure" => null,
                            "cookie_httponly" => true,
                        ], $handler);
                },
            ],
        ],
        'Filegator\Services\Cors\Cors' => [
            'handler' => '\Filegator\Services\Cors\Cors',
            'config' => [
                'enabled' => APP_ENV == 'production' ? false : true,
            ],
        ],
        'Filegator\Services\Tmpfs\TmpfsInterface' => [
            'handler' => '\Filegator\Services\Tmpfs\Adapters\Tmpfs',
            'config' => [
                'path' => __DIR__.'/private/tmp/',
                'gc_probability_perc' => 10,
                'gc_older_than' => 60 * 60 * 24 * 2, // 2 days
            ],
        ],
        'Filegator\Services\Security\Security' => [
            'handler' => '\Filegator\Services\Security\Security',
            'config' => [
                'csrf_protection' => true,
                'csrf_key' => "123456", // randomize this
                'ip_allowlist' => [],
                'ip_denylist' => [],
                'allow_insecure_overlays' => false,
            ],
        ],
        'Filegator\Services\View\ViewInterface' => [
            'handler' => '\Filegator\Services\View\Adapters\Vuejs',
            'config' => [
                'add_to_head' => '',
                'add_to_body' => '',
            ],
        ],
        'Filegator\Services\Storage\Filesystem' => [
            'handler' => '\Filegator\Services\Storage\Filesystem',
            'config' => [
                'separator' => '/',
                'config' => [],
                'adapter' => function () {
                    return new \League\Flysystem\Adapter\Local(
                        __DIR__.'/repository'
                    );
                },
            ],
        ],
        'Filegator\Services\Archiver\ArchiverInterface' => [
            'handler' => '\Filegator\Services\Archiver\Adapters\ZipArchiver',
            'config' => [],
        ],
        'Filegator\Services\Auth\AuthInterface' => [
            'handler' => '\Filegator\Services\Auth\Adapters\JsonFile',
            'config' => [
                'file' => __DIR__.'/private/users.json',
            ],
        ],
        'Filegator\Services\Router\Router' => [
            'handler' => '\Filegator\Services\Router\Router',
            'config' => [
                'query_param' => 'r',
                'routes_file' => __DIR__.'/backend/Controllers/routes.php',
            ],
        ],
    ],
];

准备配置文件主要是为了能修改语言
可以参看 https://docs.filegator.io/translations/default.html

资源清单文件

services:
  filegator:
    container_name: filegator
    image: filegator/filegator:latest
    restart: always
    ports:
      - 8080:8080
    volumes:
      - ./configuration.php:/var/www/filegator/configuration.php
      - ./repository:/var/www/filegator/repository

部署

docker compose up -d

然后就可以登陆了

http://<IP>:8080
用户名/密码:admin/admin123

登录

主页

使用总结

优点:

  1. 资源占比非常低
  2. 部署简单
  3. 多用户可以拥有私有目录
  4. 界面干净简单
  5. 操作简单易懂
  6. 可以直接展示图片pdf

不足:

  1. 用户权限过于简单,复杂点的场景无法应对
  2. 没有公告栏之类的可用于展示的信息
  3. 无法文件夹下载,只能手动打包后再手动下载
  4. 无法直接展示视频音频文档表格
  5. 无法将文件夹或者文件对外分享,例如设置密码后再进行特定的分享,而不是改全局的权限才能分享

总的来说,是个非常值得推荐的文件服务,场景不太复杂的情况下,多用户文件服务,完全可以胜任。

posted @ 2025-01-08 11:16  厚礼蝎  阅读(857)  评论(0)    收藏  举报