Description
One of the features that I built out while working with the Zooniverse team was the Azure Media Adapter, which was part of the larger effort to migrate all data from from AWS to Azure (see more about the data migration here). The existing code around media storage was written using the adapter design pattern in order to make it easy to switch service providers without needing to change the code in every place where a media file is retrieved/modified/etc.
Scope of work involved:
- Code to generate the path where the file will be stored within the relevant Azure Blob Storage container. Files are stored based on the environment, medium type, and whether the medium is public or private, and each is given a unique identifier
- Code to upload the medium to blob storage, which involves generating a URI with a Shared Access Signature that gives our API the permission to access the blob storage container
- Code to generate a URI that will provide read access to an existing medium
- Code to delete a file
- Code to translate old AWS stored paths to the correct Azure path
The Azure Adapter code was largely built upon the ‘azure-storage’, ‘azure-storage-blob’, and ‘azure-storage-common’ ruby gems.
Check out the code here.
Details
- Tools & Frameworks Ruby on Rails, Azure Blob Storage
- Code github.com/zooniverse/panoptes/commit/azure-adapter