PHP code example of hinink / laravel-seafile
1. Go to this page and download the library: Download hinink/laravel-seafile library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hinink / laravel-seafile example snippets
$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
'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', ''), # 必须
],
...
]
$upload_url = Storage::disk('seafile')->getUploadUrl();
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
MIT