When NAS storage is enabled, uploaded files go directly to the NAS share
(users/{username}/videos/{title-slug}/) with no permanent local copy kept.
Thumbnails and video are fetched from NAS on demand for streaming/playback.
When NAS is disabled, files are organised into the same directory schema
in local storage.
- VideoController: branch upload flow on NAS enabled/disabled
- NasSyncService: add uploadDirectToNas() for direct NAS writes,
organizeLocalFiles() for local NAS-schema, localVideoDir() resolver,
deleteLocalAssets() for post-sync cleanup
- GenerateHlsJob: download from NAS via ensureLocalCopy() when local
file is absent (NAS-primary mode); clean up temp after HLS generation
- CompressVideoJob: place compressed file alongside original (any dir)
- Video/VideoSlide models: localVideoPath(), localThumbnailPath(),
thumbnailStorageKey(), localPath(), storageKey() helpers for
format-agnostic path resolution (old flat paths + new NAS-schema paths)
- MediaController: serve thumbnails from NAS-mirrored paths with NAS fallback
- SuperAdminController: use model path helpers for file deletion
- NasFreeLocalStorage: scan new users/ tree in addition to legacy flat dirs
- Settings: rename "NAS Storage Sync" tab to "NAS Storage", update description
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class VideoSlide extends Model
|
|
{
|
|
protected $fillable = ['video_id', 'filename', 'position'];
|
|
|
|
public function video()
|
|
{
|
|
return $this->belongsTo(Video::class);
|
|
}
|
|
|
|
public function getUrlAttribute(): string
|
|
{
|
|
return route('media.thumbnail', $this->filename);
|
|
}
|
|
|
|
/**
|
|
* Absolute path to the slide image on local disk.
|
|
* Old format: storage/app/public/thumbnails/{filename}
|
|
* New format: storage/app/{relative-path} (filename contains a slash)
|
|
*/
|
|
public function localPath(): string
|
|
{
|
|
return str_contains($this->filename, '/')
|
|
? storage_path('app/' . $this->filename)
|
|
: storage_path('app/public/thumbnails/' . $this->filename);
|
|
}
|
|
|
|
/**
|
|
* Storage::delete()-compatible key for this slide file.
|
|
*/
|
|
public function storageKey(): string
|
|
{
|
|
return str_contains($this->filename, '/')
|
|
? $this->filename
|
|
: 'public/thumbnails/' . $this->filename;
|
|
}
|
|
}
|