skip to Main Content

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


  1. Chosen as BEST ANSWER

    For other people who are facing the same situation, here is what I ended up doing

    1. Created a single bucket on an S3 compatible storage. Make this bucket publically accessible because it will contain static assets like images.
    2. Created a folder for every user inside this bucket.
    3. Track the size of each user's folder. S3 storage, as per my knowledge, does not provide a method to get the size of the folder, so I end up getting the list of all objects in the folder and adding up their size. We calculate the size only when a file is uploaded or deleted and save the size in the DB.

    @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.


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search