I am developing an online product designing tool for Shopify. The app will be hosted on my web server. The user will put a JavaScript code on his web page. The code will open my app in an iframe(ironically that’s how Shopify apps works). The user can then use the tool to create a design and will save the generated image on my web server. What I want is to upload user generated images to a storage server, instead of storing them on my web server. I am looking for a service/solution that would allow my app to create a storage account for a user during signup and specify maximum allowed storage space. The service should also allow file upload through an API. And uploaded files should be accessible via a URL. The service should also be able to provide analytics on per user basis.
2
Answers
For other people who are facing the same situation, here is what I ended up doing
@chris suggestion for one bucket per user was good and initially I implemented this strategy, but at a later stage I faced a roadblock. I found out that S3 does not allow you to access content over HTTPS. To access content over HTTPS, we have to use Cloudflare or any other CDN, where you create a (https)zone and specify the bucket as its origin. With one bucket per user, we need to make a new zone for each new user. This situation was not ideal, as many CDNs charges extra for each new zone created. So we decided to use one bucket for all users, and create a folder for each user inside this bucket. We then created a zone on our CDN and specify the public path of the bucket as the origin of the CDN zone.
We are also planning to limit one bucket to have data for no more than 100 users, and create a new bucket after every new 100 users.
This is simple enough. Every time a customer uses your service to upload content, you know about it. So record the event in a simple data structure in your App. If the customer exceeds some limit, deal with it. You are driving the bus, so you can tell them to either pay more, get off, or leave things as is. Amazon S3 is so cheap it is never going to cost you money, and the likelihood of any customers costing you money is so low, you have about ten minutes work ahead of you to make this simple code block a thing, and go from there.