Start a Project

S3 Storage in Bagisto: Develop Locally, Deploy with Confidence

Set up S3 Storage in Bagisto and test it on your laptop first. Use a free RustFS bucket now, and switch to AWS S3 later.

No AWS account, no bill and no code changes.

The Challenge: S3 in Production, But What About Local Development?

Growing stores keep their files in a bucket. Product images and other uploads then live in one safe place, instead of on a single server.

Your local store should behave the same way. Otherwise, a bug that only shows with remote storage reaches your customers first.

The obvious fix is a real AWS bucket for every developer. It works, but it brings extra work:

A local S3-compatible server removes all of this, and S3 Storage in Bagisto works with it out of the box.

Introducing S3 Storage in Bagisto

Bagisto lets the admin choose where uploads are saved. Open Configure > File Management, and the Default Storage Driver offers three choices:

Once S3 is on, new product images, Appearance images and return request attachments land in the bucket.

Older files stay where they were. A Sync Existing Files button copies them across for you.

You enter the connection details on the Amazon S3 screen of the same group. No code is needed.

Why RustFS for Local Development?

RustFS is a free, open-source server that speaks the S3 API. It runs as one Docker container, and Bagisto treats it like any other S3 service.

Here is what you get on your machine:

Because RustFS follows the S3 API, the Bagisto code you test locally is the same code that runs against AWS.

How S3 Storage in Bagisto Works

Bagisto uses Laravel’s filesystem layer. The s3 disk and its adapter are already in the project, so you install nothing. You only add connection details.

The Amazon S3 screen has seven fields:

Files then travel in two ways. Product images are read from the bucket by Bagisto’s /cache route, using your credentials.

Other files, such as language flags, are linked straight to the URL you set, so the browser loads them from the bucket itself.

Setting Up RustFS Locally

You only need Docker. The AWS CLI is optional, but it makes the next steps quick.

Step 1: Start RustFS. The command runs the container as your own user, so you do not need sudo:

Open http://localhost:9001 and sign in with the same key and secret.

Step 2: Create a bucket. Make one named bagisto in the console, or from the terminal:

Step 3: Allow public reads. A new bucket is private, but the shopper’s browser loads some files straight from it.

This read-only policy lets anyone open files, and nothing else:

Public read is fine for a local test bucket. The production section below covers the safe way on AWS.

Configuring S3 Storage in Bagisto

S3 Storage in Bagisto has a built-in admin screen. Fill in the bucket details first, then switch the driver. The File Management docs describe each field.

Step 1: Fill in the Amazon S3 screen. Go to Configure > File Management > Amazon S3 and enter your RustFS values:

Click Save Configuration.

Step 2: Switch the driver. Go to Configure > File Management > General, set Default Storage Driver to Amazon S3 and save.

Step 3: Sync existing files. Once Amazon S3 is selected and the Amazon S3 fields are filled in, a Sync Existing Files button appears on the same screen.

It copies the files already uploaded on your server into the bucket, in the background. It skips anything already there and leaves the originals in place.

For a large store, run php artisan bagisto:storage:sync instead.

Testing S3 Storage Locally

Now test S3 Storage in Bagisto with a real upload:

  1. In the admin panel, open a product, upload an image and save.
  2. Open the RustFS console. The image sits under products/, followed by the product ID.
  3. Visit the product page on your storefront. The image should load.

If something looks off, the FAQ below covers the common causes.

From RustFS to AWS S3

Only the settings change, on the Amazon S3 screen:

Create the bucket in the AWS console, near your servers. To bring existing files across, click Sync Existing Files on the General screen.

Preparing Your Storage for Production

A bucket that works is not yet a bucket that is ready. Before S3 Storage in Bagisto goes live, take care of three things:

Keep only files you want public in this bucket, and never store private documents beside product images.

Then repeat the upload test. If the image appears in your AWS bucket and on the storefront, you are ready.

S3 Storage in Bagisto FAQ

What happens to files I uploaded before?

They do not move on their own. Click Sync Existing Files on the General screen, and Bagisto copies them in the background.

It skips files already in the bucket. For a large store, run php artisan bagisto:storage:sync instead.

Images are broken, but the upload worked. Why?

The bucket is still private. Apply the public read policy from the setup steps.

Bagisto runs inside Docker or Sail. Which address do I use?

Keep URL on localhost for the browser. Set Endpoint to an address the container can reach, such as http://rustfs:9000.

The RustFS container exits right after it starts. Why?

The data folder is not writable by the user the container runs as. Run it with --user as shown above.

Works with Bagisto extensions:

  1. Multi Vendor Marketplace: transform your store into a marketplace.
  2. Multi Tenant Commerce: a SaaS solution to launch and scale online.
  3. Headless eCommerce: API-first, flexible headless commerce.
  4. B2B Commerce: build B2B with bulk orders and catalogs.
  5. B2B Marketplace: launch a B2B marketplace for scalable trade.
  6. Mobile App: a customizable open-source eCommerce app.
  7. Bagisto Themes: pre-built stores for every business type.
  8. POS: sell in your offline store and online.
    ….. all other Extensions.

From Local Development to Production

S3 Storage in Bagisto is not a leap of faith. Develop against RustFS, deploy against AWS S3, and keep your code the same in both.

Get started today: follow the Bagisto developer docs.

Exit mobile version