Use NAS as primary storage — direct upload when enabled
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 <[email protected]>
This commit is contained in:
1 parent
296d605864
commit
6b3ab5b65e
11 files changed
+869
-125
No files matched your search
+37
-3
@@ -69,19 +69,53 @@ class Video extends Model
|
||||
return $this->slides()->count() > 1;
|
||||
}
|
||||
|
||||
// ── Local filesystem path helpers ─────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Absolute path to the video file on local disk.
|
||||
* Works for both old flat paths ("public/videos/…") and new NAS-mirrored paths ("users/…").
|
||||
*/
|
||||
public function localVideoPath(): string
|
||||
{
|
||||
return storage_path('app/' . $this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Absolute path to the thumbnail on local disk.
|
||||
* Old format: storage/app/public/thumbnails/{filename}
|
||||
* New format: storage/app/{relative-path} (path contains a slash, e.g. users/…/thumb.jpg)
|
||||
*/
|
||||
public function localThumbnailPath(): ?string
|
||||
{
|
||||
if (! $this->thumbnail) return null;
|
||||
return str_contains($this->thumbnail, '/')
|
||||
? storage_path('app/' . $this->thumbnail)
|
||||
: storage_path('app/public/thumbnails/' . $this->thumbnail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage::delete()-compatible key for the thumbnail.
|
||||
*/
|
||||
public function thumbnailStorageKey(): ?string
|
||||
{
|
||||
if (! $this->thumbnail) return null;
|
||||
return str_contains($this->thumbnail, '/')
|
||||
? $this->thumbnail
|
||||
: 'public/thumbnails/' . $this->thumbnail;
|
||||
}
|
||||
|
||||
// Accessors
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return asset('storage/videos/'.$this->filename);
|
||||
}
|
||||
|
||||
public function getThumbnailUrlAttribute()
|
||||
public function getThumbnailUrlAttribute(): ?string
|
||||
{
|
||||
if ($this->thumbnail) {
|
||||
return asset('storage/thumbnails/'.$this->thumbnail);
|
||||
return route('media.thumbnail', $this->thumbnail);
|
||||
}
|
||||
|
||||
// Return null when no thumbnail - social platforms will use their own preview
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user