ryfy
ryfy
FFilament
Created by ryfy on 9/21/2023 in #❓┊help
FileUpload disk and storeFileNamesIn settings not working
Thanks, please see above. I'm not linking a model, I'm handling the save manually. I suppose my question can be boiled down to this: If I am saving manually, do I have to use the Livewire TemporaryUploadedFile ->store() method or is there a Filament way that makes use of the disk and visibility configuration I passed to the component?
11 replies
FFilament
Created by ryfy on 9/21/2023 in #❓┊help
FileUpload disk and storeFileNamesIn settings not working
Also worth noting, I'm only using the form builder, not the filament admin. Currently the save code just uses the Livewire file upload process and configuration since that seems to be what the form builder is delivering to me. This is a small part of a much larger process involving multiple models, hence the manual save method. Here's the relevant bit of the save code:
if(isset($this->data['documents']) && !empty($this->data['documents'])) {

$user_id = $user->id;
$job_id = $job->id;
$docs = [];

foreach($this->data['documents'] as $key => $document) {
$dir = $entity->id . '/' . date('Y-m-d');
$name = $document->getClientOriginalName();
$mime = $document->getMimeType();
$meta = json_encode(['test' => true]);
try {
$path = $document->store($dir, 'private');
} catch(\Exception $e) {
DB::rollBack();
\Log::error($e->getMessage());
return;
}
$docs[] = compact('user_id', 'job_id', 'path', 'name', 'mime', 'meta');
}

try {
Document::insert($docs);
} catch(\Exception $e) {
DB::rollBack();
\Log::error($e->getMessage());
}



}
if(isset($this->data['documents']) && !empty($this->data['documents'])) {

$user_id = $user->id;
$job_id = $job->id;
$docs = [];

foreach($this->data['documents'] as $key => $document) {
$dir = $entity->id . '/' . date('Y-m-d');
$name = $document->getClientOriginalName();
$mime = $document->getMimeType();
$meta = json_encode(['test' => true]);
try {
$path = $document->store($dir, 'private');
} catch(\Exception $e) {
DB::rollBack();
\Log::error($e->getMessage());
return;
}
$docs[] = compact('user_id', 'job_id', 'path', 'name', 'mime', 'meta');
}

try {
Document::insert($docs);
} catch(\Exception $e) {
DB::rollBack();
\Log::error($e->getMessage());
}



}
This works but I would expect there to be some sort of method I could call that would handle the file upload "the Filament way" that makes uses of the configuration I set on the component. The docs for using the Form Builder in a custom application make no note of how to handle the save without a model, though it seems implied that setting a model is optional.
11 replies
FFilament
Created by ryfy on 9/21/2023 in #❓┊help
FileUpload disk and storeFileNamesIn settings not working
"documents" => array:1 [▼
"ce0c4713-fa5c-4d32-82fd-bf8d39ed29f4" => Livewire\Features\SupportFileUploads\TemporaryUploadedFile {#2142 ▼
-test: false
-originalName: "ysCY1G8lXII5SBqQL0t4PAyc0cO2XF-metaU3RlYW1QdXJjaGFzZV8yMDIxLTA2LTI5LnBkZg==-.pdf"
-mimeType: "application/octet-stream"
-error: 0
#hashName: "nbFyGFd5FluTUigvdjPRTycrb4Cc2MKvcInkOhCy"
#disk: "local"
#storage: Illuminate\Filesystem\FilesystemAdapter {#2011 ▶}
#path: "livewire-tmp/ysCY1G8lXII5SBqQL0t4PAyc0cO2XF-metaU3RlYW1QdXJjaGFzZV8yMDIxLTA2LTI5LnBkZg==-.pdf"
path: "/var/www/html/storage/app/livewire-tmp"
filename: "ysCY1G8lXII5SBqQL0t4PAyc0cO2XF-metaU3RlYW1QdXJjaGFzZV8yMDIxLTA2LTI5LnBkZg==-.pdf"
basename: "phpqw4NxX"
pathname: "/tmp/phpqw4NxX"
extension: ""
realPath: "/var/www/html/storage/app/livewire-tmp/ysCY1G8lXII5SBqQL0t4PAyc0cO2XF-metaU3RlYW1QdXJjaGFzZV8yMDIxLTA2LTI5LnBkZg==-.pdf"
size: 63865
writable: false
readable: false
executable: false
file: false
dir: false
link: false
}
]
"documents" => array:1 [▼
"ce0c4713-fa5c-4d32-82fd-bf8d39ed29f4" => Livewire\Features\SupportFileUploads\TemporaryUploadedFile {#2142 ▼
-test: false
-originalName: "ysCY1G8lXII5SBqQL0t4PAyc0cO2XF-metaU3RlYW1QdXJjaGFzZV8yMDIxLTA2LTI5LnBkZg==-.pdf"
-mimeType: "application/octet-stream"
-error: 0
#hashName: "nbFyGFd5FluTUigvdjPRTycrb4Cc2MKvcInkOhCy"
#disk: "local"
#storage: Illuminate\Filesystem\FilesystemAdapter {#2011 ▶}
#path: "livewire-tmp/ysCY1G8lXII5SBqQL0t4PAyc0cO2XF-metaU3RlYW1QdXJjaGFzZV8yMDIxLTA2LTI5LnBkZg==-.pdf"
path: "/var/www/html/storage/app/livewire-tmp"
filename: "ysCY1G8lXII5SBqQL0t4PAyc0cO2XF-metaU3RlYW1QdXJjaGFzZV8yMDIxLTA2LTI5LnBkZg==-.pdf"
basename: "phpqw4NxX"
pathname: "/tmp/phpqw4NxX"
extension: ""
realPath: "/var/www/html/storage/app/livewire-tmp/ysCY1G8lXII5SBqQL0t4PAyc0cO2XF-metaU3RlYW1QdXJjaGFzZV8yMDIxLTA2LTI5LnBkZg==-.pdf"
size: 63865
writable: false
readable: false
executable: false
file: false
dir: false
link: false
}
]
11 replies
FFilament
Created by ryfy on 9/21/2023 in #❓┊help
FileUpload disk and storeFileNamesIn settings not working
1. Yes 2. I don't have the field or form hooked to a model, I'm manually handling the save. Maybe that's where the disconnect is? I see the livewire temporary file upload but Filament doesn't appear to be doing anything with it.
11 replies