Laravel How To use another server as file storage

怎甘沉沦 提交于 2020-07-22 06:13:51

问题


I am using Laravel 7.6:

I have two Laravel projects in each server (server is normal server. Neither AWS nor Digital Ocean, Just dedicated server).

Project1 is in server1.

Project2 is in server2.

My question is:

How can I do CRUD from Project1 To server2?

So in Project1 I would like to read, upload, delete, edit files which are in server2. This is my current filesystem configuration.

  'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
        ],

    ],

Can I make and use something like this?

           'public' => [
                'driver' => 'custom',
                'root' => storage_path('app/public'),
                'url' => 'my-another-server-url',
                'visibility' => 'public',
            ],

I think this is quite possible if two projects are in same server (using local driver).

Both server can be provided by the same hosting provider but I will put them in each server.

I think this package (https://github.com/thephpleague/flysystem) gives me some solution.

Should I make API in project 2?

Can anyone help me with some instruction and recommending packages?

Thanks.

来源:https://stackoverflow.com/questions/62484466/laravel-how-to-use-another-server-as-file-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!