Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Jonjie's avatar
Level 12

Unable to write file at location in spatie google cloud storage laravel

I'm trying to upload file on my google cloud storage using https://github.com/spatie/laravel-google-cloud-storage but unfortunately Im getting an error. Please see my code below together with the error Im getting.

filesystems.php

'gcs' => [
         'driver' => 'gcs',
         'key_file_path' => env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json
         'key_file' => [], // optional: Array of data that substitutes the .json file (see below)
         'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'), // optional: is included in key file
         'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
         'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', ''), // optional: /default/path/to/apply/in/bucket
         'apiEndpoint' => env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below
         'visibility' => 'noPredefinedVisibility', // optional: public|private
         'metadata' => ['cacheControl'=> 'public,max-age=86400'], // optional: default metadata
         'throw' => true
]

Error

"message": "Unable to write file at location:" "exception": "League\Flysystem\UnableToWriteFile"

0 likes
4 replies
imatteh's avatar

If you encounter an error "File not found" you might want to set the name to an empty string inside the backup configuration file.

// config/backup.php

'name' => '',

That is it.

1 like

Please or to participate in this conversation.