F
Filament3mo ago
kisut

Unable to check existence S3 Storage R2 Cloudflare

Hi, I'm using R2 Cloudflare, the file successfully uploaded to bucket, but it's getting error
Unable to check existence for: release/cover-art/file-name.jpg
Unable to check existence for: release/cover-art/file-name.jpg
My resource
Forms\Components\FileUpload::make('cover_art')
->disk('s3')
->directory('release/cover-art')
->storeFileNamesIn('original_image_name')
Forms\Components\FileUpload::make('cover_art')
->disk('s3')
->directory('release/cover-art')
->storeFileNamesIn('original_image_name')
Filesystem
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'directory_env' => env('AWS_DIRECTORY'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'bucket_endpoint' => true,
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'directory_env' => env('AWS_DIRECTORY'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'bucket_endpoint' => true,
'visibility' => 'public',
],
Any thoughts about this?
Solution:
SOLVED! This requires SSL and I forgot to enable it on local
Jump to solution
21 Replies
Dennis Koch
Dennis Koch3mo ago
This is probably an error from the Filesystem driver and not Filament, right? Sounds like some issue with access permissions
kisut
kisutOP3mo ago
What do you think I should change?
Dennis Koch
Dennis Koch3mo ago
I don't know. I never worked with R2. Check the permissions Isn't there more information why it is unable to check existence? Does R2 support the nested folder structure?
kisut
kisutOP3mo ago
I got error like this, is
visibility => 'public'
visibility => 'public'
not enough?
No description
kisut
kisutOP3mo ago
I have no clue about this😢
[
{
"AllowedOrigins": [
"https://admin.soundmera.com"
],
"AllowedMethods": [
"GET",
"POST",
"DELETE",
"PUT",
"HEAD"
],
"AllowedHeaders": [
"*"
],
"ExposeHeaders": [
"Access-Control-Allow-Origin",
"x-amz-server-side-encryption",
"x-amz-request-id",
"x-amz-id-2",
"Content-Type"
],
"MaxAgeSeconds": 3000
}
]
[
{
"AllowedOrigins": [
"https://admin.soundmera.com"
],
"AllowedMethods": [
"GET",
"POST",
"DELETE",
"PUT",
"HEAD"
],
"AllowedHeaders": [
"*"
],
"ExposeHeaders": [
"Access-Control-Allow-Origin",
"x-amz-server-side-encryption",
"x-amz-request-id",
"x-amz-id-2",
"Content-Type"
],
"MaxAgeSeconds": 3000
}
]
Here is my CORS policy for R2 Bucket
Dennis Koch
Dennis Koch3mo ago
CORS is client side, not server side, and therefore unrelated.
awcodes
awcodes3mo ago
The visibility probably needs to be set to private like s3. Then you also need to check the bucket permissions themselves for the r2 user.
kisut
kisutOP3mo ago
Already set the permissions to read & write and change the visibility to private, but the error is still there.
No description
awcodes
awcodes3mo ago
You might need to offload the livewire tmp directory to the bucket too. https://livewire.laravel.com/docs/uploads#uploading-directly-to-amazon-s3 This is specifically for s3, but it should work the same way with R2.
Laravel
File Uploads | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
awcodes
awcodes3mo ago
I’m think that r2 is trying to read from your local disk. I could be wrong though.
kisut
kisutOP3mo ago
Do you mean like this? If so, I've set the disk to s3 as well.
'temporary_file_upload' => [
'disk' => 's3', // Example: 'local', 's3' | Default: 'default'
'rules' => null, // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB)
'directory' => 'release/cover-art', // Example: 'tmp' | Default: 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs...
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
'mov', 'avi', 'wmv', 'mp3', 'm4a',
'jpg', 'jpeg', 'mpga', 'webp', 'wma',
],
'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
],
'temporary_file_upload' => [
'disk' => 's3', // Example: 'local', 's3' | Default: 'default'
'rules' => null, // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB)
'directory' => 'release/cover-art', // Example: 'tmp' | Default: 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs...
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
'mov', 'avi', 'wmv', 'mp3', 'm4a',
'jpg', 'jpeg', 'mpga', 'webp', 'wma',
],
'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
],
This is what I'm confused about, the upload process has gone well, but I don't know where the error is when r2 read the file
awcodes
awcodes3mo ago
Shouldn’t the disk be r2, not s3?
kisut
kisutOP3mo ago
I'm setting the R2 on top of the S3 disk that is already in the filesystem.
awcodes
awcodes3mo ago
Hmm. Not totally sure at this point. Sorry.
kisut
kisutOP3mo ago
😭
awcodes
awcodes3mo ago
I would expect this to work:
FileUpload::make()
->disk(‘s3’)
->directory()
->visibility(‘private’)
FileUpload::make()
->disk(‘s3’)
->directory()
->visibility(‘private’)
Definitely sounds like something between cloudflare and s3 and not anything in Filament though.
kisut
kisutOP3mo ago
Already set it though, but the error persist
Forms\Components\FileUpload::make('cover_art')
->disk('s3')
->directory('release/cover-art')
->storeFileNamesIn('original_image_name')
->visibility('private')
Forms\Components\FileUpload::make('cover_art')
->disk('s3')
->directory('release/cover-art')
->storeFileNamesIn('original_image_name')
->visibility('private')
awcodes
awcodes3mo ago
Yea. It’s something upstream with the remote as best I can tell. Can you try it without the filename adjustment?
kisut
kisutOP3mo ago
It seems like the same thing, the same error appears again
awcodes
awcodes3mo ago
Ok. Sorry, I can’t help more then. But seems like the issue is outside filament or laravel at this point.
Solution
kisut
kisut3mo ago
SOLVED! This requires SSL and I forgot to enable it on local
Want results from more Discord servers?
Add your server