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:
@@ -40,7 +40,8 @@ $adminMode = $adminMode ?? false;
|
||||
<input type="file" id="tfe-files-input"
|
||||
name="queue_file[tfe][]" multiple
|
||||
accept=".pdf,.jpg,.jpeg,.png,.gif,.webp,.mp4,.webm,.mov,.ogv,.mp3,.ogg,.oga,.wav,.flac,.aac,.m4a,.vtt"
|
||||
class="tfe-file-picker">
|
||||
class="tfe-file-picker"
|
||||
data-queue-type="tfe">
|
||||
<small class="admin-file-hint">
|
||||
Types acceptés : PDF · JPG/PNG/GIF/WEBP · MP4/WebM/MOV (vidéo) · MP3/OGG/WAV/FLAC (audio) · ZIP/TAR (archives). Max 500 MB par fichier.
|
||||
Les fichiers <code>.vtt</code> sont des sous-titres et seront associés automatiquement à la vidéo précédente.
|
||||
|
||||
@@ -145,6 +145,7 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
|
||||
<form action="<?= $formAction ?>" method="post" enctype="multipart/form-data" class="admin-form" data-beforeunload-guard data-upload-progress>
|
||||
<input type="hidden" name="progress_token" value="<?= bin2hex(random_bytes(8)) ?>">
|
||||
<input type="hidden" name="filepond_mode" value="1">
|
||||
<?= $hiddenFields ?>
|
||||
|
||||
<?php if (!$adminMode): ?>
|
||||
@@ -322,6 +323,25 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
$_POST['website_label'] = $existingWebsiteLabel;
|
||||
$_POST['admin_mode'] = $adminMode ? '1' : '0';
|
||||
$_POST['has_annexes'] = $formData['has_annexes'] ?? null;
|
||||
|
||||
// Build existing-files JSON for FilePond edit mode
|
||||
$existingFilesJsonForTfe = [];
|
||||
if (!empty($currentFiles)) {
|
||||
foreach ($currentFiles as $f) {
|
||||
$ft = $f['file_type'] ?? '';
|
||||
$fp = $f['file_path'] ?? '';
|
||||
// Skip cover (handled separately) and website/peertube (no actual file)
|
||||
if ($ft === 'cover' || str_starts_with($fp, 'http://') || str_starts_with($fp, 'https://') || str_starts_with($fp, 'peertube_ids:')) {
|
||||
continue;
|
||||
}
|
||||
// Only include files that can be streamed back via load.php
|
||||
$existingFilesJsonForTfe[] = [
|
||||
'source' => (string)((int)$f['id']),
|
||||
'options' => ['type' => 'local'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
include APP_ROOT . '/public/partage/fichiers-fragment.php';
|
||||
$_POST = $_savedPost;
|
||||
unset($_savedPost);
|
||||
@@ -338,6 +358,25 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
$_POST['edit_mode'] = '1';
|
||||
$_POST['_cover'] = $currentCover['file_path'] ?? null;
|
||||
$_POST['has_annexes'] = $formData['has_annexes'] ?? null;
|
||||
|
||||
// Build existing-files JSON for FilePond edit mode
|
||||
$existingFilesJsonForTfe = [];
|
||||
if (!empty($currentFiles)) {
|
||||
foreach ($currentFiles as $f) {
|
||||
$ft = $f['file_type'] ?? '';
|
||||
$fp = $f['file_path'] ?? '';
|
||||
// Skip cover (handled separately) and website/peertube (no actual file)
|
||||
if ($ft === 'cover' || str_starts_with($fp, 'http://') || str_starts_with($fp, 'https://') || str_starts_with($fp, 'peertube_ids:')) {
|
||||
continue;
|
||||
}
|
||||
// Only include files that can be streamed back via load.php
|
||||
$existingFilesJsonForTfe[] = [
|
||||
'source' => (string)((int)$f['id']),
|
||||
'options' => ['type' => 'local'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
include APP_ROOT . '/public/partage/fichiers-fragment.php';
|
||||
$_POST = $_savedPost;
|
||||
unset($_savedPost);
|
||||
|
||||
Reference in New Issue
Block a user