Skip to content

hinink/laravel-seafile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flysystem Adapter for SeaFile

Requirement

PHP >= 7.4
Laravel >= 6

Installation

composer require "hinink/laravel-seafile"

Usages

SeaFile Api Doc

    $storage = Storage::disk('seafile');
    
    $storage->put('save file path', 'contents');
    
    $storage->putFileAs('save path', 'file', 'save name');
    
    $storage->getMetadata('file path');
    
    $storage->getSize('file path');
    
    $storage->getTimestamp('file path');
    
    $storage->getMimetype('file path');
    
    $storage->listContents('path');
    
    $storage->directories('path');
    
    $storage->files('path');
    
    $storage->exists('file path');
    
    $storage->makeDirectory('dir name');
    
    $storage->delete('file path');
    
    $storage->deleteDir('dir name');
    
    $storage->getUploadUrl();       
                  
    
    $storage->rename('file path', 'new name')  
       
    $storage->url('file path');        # Disposable 
    $storage->url(['url'=>'file path','cache'=>true]);  # Valid for one hour

Config filesystems.php add

'disks'=>[
     ....
     
    'seafile' => [
        'driver'   => 'seaFile',                    # 必须
        'server'   => env('SEAFILE_SERVER', ''),    # 必须
        'username' => env('SEAFILE_USER', ''),      # 
        'password' => env('SEAFILE_PASSWORD', ''),
        'token'    => env('SEAFILE_TOKEN', ''),     # 
        'repo_id'  => env('SEAFILE_REPO_ID', ''),   # 必须	    	
    ],
    
   ...
]

Token or username password method

Direct file transmission

  1. getUploadUrl
    $upload_url = Storage::disk('seafile')->getUploadUrl();
  1. upload file
    post $upload_url
    url params: ret-json=1  返回 json    
    body params
         'file': (filename, fileobj),
         'parent_dir':  保存的父级地址 固定值 '/'
         'relative_path': 文件保存路径
         'replace': 1,0  是否覆盖
    
    respon
        json [{"name": "1.mp4", "id": "4f5022acac09f3112c02f07ee09d8d093064e4ad", "size": 302668280}]
        str  4f5022acac09f3112c02f07ee09d8d093064e4ad        
        

Refer To

License

MIT

About

sea file for laravel storage

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages