phpgoogle-cloud-platformfile-uploadlaravel-filament

FIlament PHP | FileUpload Issue | Waiting for size | GCP


I need your help with FileUpload using GCP. I have two ways of uploading images:

  1. Using RichEditor: This one works perfectly. Basically, when I upload the image, I can see them without any issues.
  2. Using FileUpload: This is where I encounter the issue. I was able to upload it and I can open the file; however, the preview keeps on loading and telling me "waiting for size" forever.

Here's my resource code:

Forms\Components\FileUpload::make('attachments')
                                    ->columnSpan(2)
                                    ->fetchFileInformation(false)
                                    ->label('Attachments')
                                    ->multiple()
                                    ->previewable()
                                    ->reorderable()
                                    ->downloadable()
                                    ->openable()
                                    ->directory('attachments')
                                    ->storeFileNamesIn('original_filenames')
                                    ->disabled($user
                                        ->cannot('admin:customer_support_request:view_attachments'))
                                    ->hidden($user
                                        ->cannot('admin:customer_support_request:edit_attachments')),

Here's my filesystem.php file code:

'gcs-media' => [
            'driver' => 'gcs',
            'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'project_id'),
            'bucket' => env('GOOGLE_CLOUD_MEDIA_STORAGE_BUCKET', 'test.com'),
            'visibility' => 'public',
            'bucket_url' => env('GOOGLE_CLOUD_MEDIA_BUCKET_URL'),
            'storage_api_uri' => env('GOOGLE_CLOUD_MEDIA_BUCKET_URL'),
            'visibility_handler' => \League\Flysystem\GoogleCloudStorage\UniformBucketLevelAccessVisibility::class,
            'key_file' => [
                'type' => env('GOOGLE_CLOUD_MEDIA_ACCOUNT_TYPE'),
                'private_key_id' => env('GOOGLE_CLOUD_MEDIA_PRIVATE_KEY_ID'),
                'private_key' => env('GOOGLE_CLOUD_MEDIA_PRIVATE_KEY'),
                'client_email' => env('GOOGLE_CLOUD_MEDIA_CLIENT_EMAIL'),
                'client_id' => env('GOOGLE_CLOUD_MEDIA_CLIENT_ID'),
                'auth_uri' => env('GOOGLE_CLOUD_MEDIA_AUTH_URI'),
                'token_uri' => env('GOOGLE_CLOUD_MEDIA_TOKEN_URI'),
                'auth_provider_x509_cert_url' => env('GOOGLE_CLOUD_MEDIA_AUTH_PROVIDER_CERT_URL'),
                'client_x509_cert_url' => env('GOOGLE_CLOUD_MEDIA_CLIENT_CERT_URL'),
            ],
            'throw' => true,
        ],

I have already updated my .env file the APP_URL there and seems to be correct because I was able to upload the file in my GCP and I can see the images when using RichEditor. I have also tried updating the php.ini file to: variables_order = GPCS but nothing works. I have already added this: ->fetchFileInformation(false) and it is still the same. Can anyone assist me with this. Thank you.


Solution

  • This has been fixed on the server side. CORS is not enabled. All you need to do is allow access from the source.