Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making a request to an ActiveStorage resource fails occasionally #666

Open
febincloudyuga opened this issue Apr 28, 2021 · 0 comments
Open

Comments

@febincloudyuga
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant