Skip to content

Making a request to an ActiveStorage resource fails occasionally #666

@febincloudyuga

Description

@febincloudyuga

Use-case

We're using Apartment alongside ActiveStorage.
In our S3 server, we have created a bucket for every tenant in our application.
Since ActiveStorage can hold only one bucket globally, we're switching the ActiveStorage bucket for every request.

The problem

When a request from one tenant is being served and a new request from another tenant comes in, the bucket held by ActiveStorage gets switched to that of the new tenant.
Now if the first tenant request is trying to access a resource in ActiveStorage, it results in a failure since request is being made with incorrect bucket name

Current workaround

A fallback mechanism to check if the generated ActiveStorage URL is valid. If it's invalid, change the bucket name held by ActiveStorage to that of the current tenant and make a new request

Pictorial representation attached.

Apartment

Kindly let us know if there's a better way of solving this problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions