Using Digital Ocean Spaces with Laravel

Storing file in Digitalocean spaces

Hafiq Iqmal
4 min readSep 20, 2022


Digital Ocean Spaces is a service much like AWS S3 that allows users to save files. Spaces uses an API that mirrors that of S3 means it is 100% compatible with AWS S3. Spaces have a built-in CDN that makes data storage and delivery easy, reliable and affordable.

The price? DO Spaces offer $5 per month, you get 250GB of storage and 1TB of bandwidth included. Extra storage costs is $0.02 per GB and additional bandwidth is just $0.01 per GB. It is very affordable cloud file storage provided by Digital Ocean compared to Amazon S3. If budget are your concern, DO Spaces are good to go.

Setting Up

Out of the box, Laravel provides support for S3 and the DO Spaces has a S3 compatible API for the flysystem driver. So, make sure you have already pulled in the FlySystem S3 drivers into your Laravel project. If not, install below package.

> composer require league/flysystem-aws-s3-v3

Creating Spaces

Creating your first Space automatically starts your Spaces subscription. Your subscription automatically ends when you destroy all of your Spaces. You can create a Space at any time from the Create menu by selecting Spaces and it will take you to the Create a Space page. You may follow the steps below:-

  1. Choose a datacenter region. The datacenter region you choose will also become part of a Space’s endpoint URL. See regional availability for Spaces for more information on the available options.
  2. Optionally, enable the Spaces CDN (Content Delivery Network). If you click Enable CDN, you can customize the Edge Cache TTL, which is the amount of time the edge servers will cache your content.
  3. Choose to restrict file listing or enable file listing. The visibility of a Space’s file listing has no effect on the visibility of the files themselves. You can change the file listing visibility at any time after creation.
  4. Choose a unique name for your Space. The name of the Space makes up part of its endpoint URL and cannot be changed once it is created. Please choose a unique name. Same rules as Amazon S3.
  5. Select a project to add the…



Hafiq Iqmal

Tech Lead Developer | Software Engineer | Laravel Enthusiasts | CTF Newbie | Medium writer | UiTM Alumni | Husband | Proud father of a beautiful daughter