Media Server

Introduction

The "media" within the ComUnity Platform's Media Services alludes to the diverse range of content types that the platform can handle, enriching the architecture of digital solutions. The Media Services component of the ComUnity Platform offers a robust layer that efficiently processes requests for every content type it supports. This encompasses two main categories: structured and unstructured data.

Structured Data Handling

Structured data transactions leverage the OData protocol, presenting a dual interface comprising an API for data manipulation and a URL-based query domain-specific language (DSL) for information retrieval. This approach ensures:

  • Data Parsing: Interprets OData requests to determine the appropriate data entities, supporting authorisation and adherence to data governance policies.

  • Value-Added Processing: Prior to data relay to the business logic layer, the system performs essential processing for optimisation.

  • Error Handling: Enhances the developer experience by appending diagnostic information to errors for quicker resolution.

Unstructured Data Management

Unstructured data, particularly a wide array of file types, is handled with robust capabilities:

  • Azure Blob Storage Integration: Seamlessly uploads and downloads large files (up to 270 GB), featuring functionalities such as de-duplication, download resumption, and cache management.

  • HTTP Feature Utilisation: Employs partial GET requests, enabling browsers to manage video playback efficiently when accessing large video files hosted on the platform.

Specialised Media Processing

The platform excels in media adaptation and optimisation through:

  • Image Transformation Pipeline: Utilises a declarative approach for dynamic image processing, which adapts content according to device capabilities to optimise bandwidth and processing requirements.

  • Caching Mechanism: Improves performance by caching image transformations, minimising CPU usage on subsequent requests.

Iconography Support

Delivering a comprehensive icon set handling, the server:

  • SVG API Utilisation: Offers access to standard icon repositories, including Font Awesome, Noun Project, and Material Design, complete with on-the-fly rasterisation connected to the image transformation pipeline for efficient icon generation.

By default the ComUnity Developer Toolkit Media Server supports anonymous public read access to storage resources, to increase the security of your applications you may opt to use the managed media server as it only allows permission based and time-bound access to storage resources.

// Supported file formats:
Extension -> MIME type
		.jar 		application/java-archive
		.json 		application/json
		.doc 		application/msword
		.bin 		application/octet-stream
		.pdf 		application/pdf
		.crl 		application/pkix-crl
		.eps 		application/postscript
		.apk 		application/vnd.android.package-archive
		.xls 		application/vnd.ms-excel
		.xlsm 		application/vnd.ms-excel.sheet.macroEnabled.12
		.ppt 		application/vnd.ms-powerpoint
		.pptm 		application/vnd.ms-powerpoint.presentation.macroEnabled.12
		.docm 		application/vnd.ms-word.document.macroEnabled.12
		.xps 		application/vnd.ms-xpsdocument
		.xlsx 		application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
		.docx 		application/vnd.openxmlformats-officedocument.wordprocessingml.document
		.pptx 		application/vnd.openxmlformats-officedocument.presentationml.presentation
		.cod 		application/vnd.rim.cod
		.rm 		application/vnd.rn-realmedia
		.wasm 		application/wasm
		.xhtml 		application/xhtml+xml
		.z 			application/x-compress
		.manifest 	application/x-ms-manifest
		.gz 		application/x-gzip
		.swf 		application/x-shockwave-flash
		.tar 		application/x-tar
		.zip 		application/x-zip-compressed
		.midi 		audio/mid
		.mp3 		audio/mpeg
		.oga 		audio/ogg
		.wav 		audio/wav
		.wma 		audio/x-ms-wma
		.bmp 		image/bmp
		.gif 		image/gif
		.jpg 		image/jpeg
		.png 		image/png
		.svg 		image/svg+xml
		.tiff 		image/tiff
		.ico 		image/x-icon
		.pnm 		image/x-portable-anymap
		.wbmp 		image/vnd.wap.wbmp
		.plist 		application/x-plist
		.mht 		message/rfc822
		.css 		text/css
		.csv 		text/csv
		.html 		text/html
		.js 		text/javascript
		.txt 		text/plain
		.jad 		text/vnd.sun.j2me.app-descriptor
		.xml 		text/xml
		.vcf 		text/x-vcard
		.3gp 		video/3gpp
		.avi 		video/avi
		.mov 		video/quicktime
		.mp4 		video/mp4
		.mpg 		video/mpeg
		.ogg 		video/ogg
		.webm 		video/webm
		.flv 		video/x-flv
		.asf 		video/x-ms-asf
		.wmv 		video/x-ms-wmv
		.movie 		video/x-sgi-movie
		.msg 		application/vnd.ms-outlook

Managing file uploads

SHA File Naming

All files uploaded to the media follow a SHA’s standard file naming convention:

Although use of the SHA File Naming convection prevents duplicate file uploads, its main disadvantage is that uploading an existing file/s are overwritten.

Image file types

SHA_of_file.red.green.blue.alpha.width.height.file_extension 
e.g.
081b278349bb8499788bca8427f11063c73a666a66a8422840311e3397de5ad5.186.188.189.0.300.300.png

Other file types

SHA_of_file.file_extension
e.g.
0aa941b04274ae04dc5a9bd214f7d5214f36e6de.txt 
4dac5a4344f76fdcc496af643cfb094de5fcc6743f8e125c1e4c4415d5115a0c.xml 

The Filenames Data Service maintains a mapping of the original file name (or friendly name) to the SHA name.

Upload a single file

// Example of uploading an image to the Breede app media server using POSTMAN
POST https://breede.qa.comunity.me/u/web_main_menu.png HTTP/1.1
		Content-Type: application/octet-stream
		User-Agent: PostmanRuntime/7.32.3
		Accept: */*
		Cache-Control: no-cache
		Postman-Token: dc9d1faa-56e6-4c11-b7f6-46a4d532fcc7
		Host: breede.qa.comunity.me
		Accept-Encoding: gzip, deflate, br
		Connection: keep-alive
		Content-Length: 944662
		<binary file content>
		
		HTTP/1.1 201 Created
		Server: Microsoft-HTTPAPI/2.0
		access-control-allow-headers: Authorization,Content-Type,Cache-Control,X-Requested-With,X-XSRF-TOKEN,If-None-Match,X-Original-Id
		access-control-allow-origin: *
		access-control-allow-methods: GET,POST,PUT,DELETE,PATCH,OPTIONS
		Location: /u/d/e04507068cd8da2e65eb3cbd7968265e876f94daaae38086ab08c9ce34293041.202.194.189.0.1852.1135.png
		ETag: "f062bd36e355276449b5e0f88ba9a82bae9b694cf1b208b5e84defff0acf1830"
		Date: Fri, 07 Jul 2023 10:55:03 GMT
		Content-Length: 92
		e04507068cd8da2e65eb3cbd7968265e876f94daaae38086ab08c9ce34293041.202.194.189.0.1852.1135.png

Retrieve files

The format of the URL used to retrieve storage resources from a public Media server:

<<Base URL>>/u/<<args>>

Notes:

  • Base URL: this specifies the base url of your project, during development its https://toolkitv3.comunity.me

  • u : this segment of the URL denotes the Media Server, it is required.

  • args represent various arguments or parameters which are used to define your search.

Image manipulation

When fetching images from the Media Server you can append optional arguments to the URL string which allow you to manipulate your images. These modifiers used to manipulate images are derived from Graphics Magick.

The table below describes the image modifiers supported in the Media Server:

The descriptions in the table below were generated using Chat GPT.