Although directories are an illusion in S3, they're still useful due to the prefix filtering capabilities of the S3 API. There are a lot of common strategies for organizing objects in S3, but the most important rule is:
Organization matters.
Schema architecture matters in a SQL database, and prefix architecture matters in S3. We always want to group objects in a way that makes sense for our case, because often we'll want to operate on a group of objects at once.
For example, pretend you do the naive thing and upload all your images to the root of your bucket. What happens if...
If you don't have any prefixes (directories) to group objects, you might find yourself iterating over every object in the bucket to find the ones you care about. That's slow and expensive.
Tubely's software architect has decided on the following prefix "schema" for our video uploads:
landscape (16:9 aspect ratio)portrait (9:16 aspect ratio)other (everything else)# mac
brew install ffmpeg
# linux
sudo apt install ffmpeg
ffprobe -version
ffmpeg -version
ffprobe -v error -print_format json -show_streams PATH_TO_VIDEO
You should see a streams array containing information about the video. We care about the width and height fields of the first stream.
Aspect ratios might be slightly off due to rounding errors. You can use a tolerance range (or just use integer division and call it a day).
Run and submit the CLI tests.