mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
filepond: implement async server-ID upload architecture with nested queue support + PeerTube integration
Replace `storeAsFile:true` with a full async FilePond round-trip pipeline using opaque server-side file IDs.
* Added 4 new PHP endpoints under `/admin/actions/filepond/`:
* `process.php` — upload/process single file and return opaque `file_id`
* `revert.php` — delete pending tmp uploads before form submit
* `load.php` — stream existing files by DB ID for FilePond preload
* `remove.php` — soft-delete `thesis_files` rows
* `process.php` improvements:
* accept arbitrary FilePond field names instead of hardcoded `file`
* support PHP-nested multi-file queue inputs (`queue_file[tfe][]`)
* explicit unwrapping of nested `$_FILES` structures
* add `audio/mp3` to audio + `peertube_audio` MIME whitelists
* immediate upload of `peertube_*` files to PeerTube, returning `peertube:{uuid}` IDs
* extensive `error_log()` instrumentation for request, CSRF, MIME, upload, and save stages
* `revert.php` now accepts `peertube:` IDs without local cleanup
* `ThesisFileHandler`:
* add `handleFilePondQueueFiles()` + `handleFilePondSingleFile()`
* process async uploads from `storage/tmp/filepond/` via opaque `file_id`
* inline handling of `peertube:{uuid}` IDs with direct `thesis_files` insertion
* remove obsolete deferred PeerTube queue-processing flow
* `ThesisCreateController` + `ThesisEditController`:
* gate async path behind `filepond_mode=1`
* preserve legacy multipart flow as fallback
* `file-upload-filepond.js`:
* remove `storeAsFile:true`
* add `buildServerConfig()` for async endpoint wiring
* fix `syncOrderInput()` to use `serverId`
* add `onprocessfile` hook
* add `fileValidateSizeFilterItem` for per-extension size caps
* preload existing uploads via `data-existing-files` + `server.load`
* replace static `INPUT_ID_TO_TYPE` map with `data-queue-type`
* add extensive `console.log()` debugging across upload pipeline stages
* `upload-progress.js`:
* block form submission while uploads are pending
* update `collectFileNames()` to read processed FilePond items
* Templates/layout:
* add `data-queue-type`
* add `data-existing-files`
* add global CSRF meta tag outside admin-only context
* add `filepond_mode` hidden input
* add CSRF token/meta support for partage pages
* move website URL field below file upload block
* `.gitignore`: exclude `storage/tmp/` from version control
This commit is contained in:
@@ -194,26 +194,38 @@ class ThesisCreateController
|
||||
$folderPath = 'theses/' . $data['annee'] . '/' . $folderName . '/';
|
||||
$filePrefix = $folderName;
|
||||
|
||||
$this->handleCoverUpload($thesisId, $files['couverture'] ?? null, $folderPath, $filePrefix);
|
||||
$this->handleNoteIntentionUpload($thesisId, $files['note_intention'] ?? null, $folderPath, $filePrefix);
|
||||
if (!empty($post['filepond_mode'])) {
|
||||
// New path: files already on server via async FilePond uploads
|
||||
// Cover and note_intention also go through FilePond async flow
|
||||
$this->handleFilePondSingleFile($thesisId, $post, 'cover', $folderPath, $filePrefix);
|
||||
$this->handleFilePondSingleFile($thesisId, $post, 'note_intention', $folderPath, $filePrefix);
|
||||
$nextNum = $this->handleFilePondQueueFiles($thesisId, $post, 'tfe', $folderPath, $filePrefix, 1);
|
||||
$nextNum = $this->handleFilePondQueueFiles($thesisId, $post, 'video', $folderPath, $filePrefix, $nextNum);
|
||||
$nextNum = $this->handleFilePondQueueFiles($thesisId, $post, 'audio', $folderPath, $filePrefix, $nextNum);
|
||||
$this->handleFilePondQueueFiles($thesisId, $post, 'annexe', $folderPath, $filePrefix, 0);
|
||||
$this->handleFilePondQueueFiles($thesisId, $post, 'peertube_video', $folderPath, $filePrefix, 0, null);
|
||||
$this->handleFilePondQueueFiles($thesisId, $post, 'peertube_audio', $folderPath, $filePrefix, 0, null);
|
||||
} else {
|
||||
// Legacy path: files arrive via multipart $_FILES
|
||||
$this->handleCoverUpload($thesisId, $files['couverture'] ?? null, $folderPath, $filePrefix);
|
||||
$this->handleNoteIntentionUpload($thesisId, $files['note_intention'] ?? null, $folderPath, $filePrefix);
|
||||
$queueFiles = $files['queue_file'] ?? [];
|
||||
$qTfe = $this->extractFilesSubArray($queueFiles, 'tfe');
|
||||
$qVideo = $this->extractFilesSubArray($queueFiles, 'video');
|
||||
$qAudio = $this->extractFilesSubArray($queueFiles, 'audio');
|
||||
$qAnnexe = $this->extractFilesSubArray($queueFiles, 'annexe');
|
||||
|
||||
// TFE files from client-side JS queue (FormData)
|
||||
$queueFiles = $files['queue_file'] ?? [];
|
||||
$qTfe = $this->extractFilesSubArray($queueFiles, 'tfe');
|
||||
$qVideo = $this->extractFilesSubArray($queueFiles, 'video');
|
||||
$qAudio = $this->extractFilesSubArray($queueFiles, 'audio');
|
||||
$qAnnexe = $this->extractFilesSubArray($queueFiles, 'annexe');
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qTfe, $folderPath, $filePrefix, 1);
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qVideo, $folderPath, $filePrefix, $nextNum);
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qAudio, $folderPath, $filePrefix, $nextNum);
|
||||
$this->handleAnnexeQueueFiles($thesisId, $qAnnexe, $folderPath, $filePrefix);
|
||||
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qTfe, $folderPath, $filePrefix, 1);
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qVideo, $folderPath, $filePrefix, $nextNum);
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qAudio, $folderPath, $filePrefix, $nextNum);
|
||||
$this->handleAnnexeQueueFiles($thesisId, $qAnnexe, $folderPath, $filePrefix);
|
||||
|
||||
// ── 5b. PeerTube video / audio uploads (from FilePond queue) ──────────
|
||||
$qPTVideo = $this->extractFilesSubArray($queueFiles, 'peertube_video');
|
||||
$qPTAudio = $this->extractFilesSubArray($queueFiles, 'peertube_audio');
|
||||
$this->handlePeerTubeQueueFiles($thesisId, $data['titre'], $qPTVideo, 'video');
|
||||
$this->handlePeerTubeQueueFiles($thesisId, $data['titre'], $qPTAudio, 'audio');
|
||||
// ── 5b. PeerTube video / audio uploads (from FilePond queue) ──────────
|
||||
$qPTVideo = $this->extractFilesSubArray($queueFiles, 'peertube_video');
|
||||
$qPTAudio = $this->extractFilesSubArray($queueFiles, 'peertube_audio');
|
||||
$this->handlePeerTubeQueueFiles($thesisId, $data['titre'], $qPTVideo, 'video');
|
||||
$this->handlePeerTubeQueueFiles($thesisId, $data['titre'], $qPTAudio, 'audio');
|
||||
}
|
||||
|
||||
// ── 6. Website URL — stored as thesis_files row ──────────────────────
|
||||
$this->handleWebsiteUrl($thesisId, $post);
|
||||
|
||||
Reference in New Issue
Block a user