Storage Service For A Shopify Application

- 1 answer

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.



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.