Giter VIP home page Giter VIP logo

contessa's Introduction

Build Status

Contessa

A very simple media content service, built on Spring Boot. Provides a quick and easy way to manage the storage, upload and access to media and assets, in a situation where a real CDN may not (yet) be a viable solution.

Quickstart

Contessa is packaged as a fat-jar, and can be started by simply running it. The minimal required configuration is to set the base-dir property, which is required, and starting won't be possible without it.

  $ java -Dcontessa.base-dir=data/ -jar contessa.jar

You can now browse http://localhost:8080 and you should see some application information.

There are two main user interfaces on top of HTTP; a straight-forward web, and a REST-ful API mapped to http://localhost:8080/api/v1. The REST-ful API does not serve the actual content, but rather provides content entries as application/json resources.

All content entry data is served from the web UI.

Adding content via the web UI

Users will typically upload some named content, and capture the response, which will be the unique content entry URI.

  $ curl --request POST \
         --header "content-type: application/octet-stream" \
         --data-binary "@some.gif" \
         http://localhost:8080/some.gif
  http://localhost:8080/ede542cb-f8ec1d4.gif

The returned URI is calculated to be unique, both with regards to the data as well as the name.

If we request the URI we can see that Contessa will return a cache-control header, which by default uses a max-age of 100 days.

  $ curl -I http://localhost:8080/ede542cb-f8ec1d4.gif
  HTTP/1.1 200
  ETag: "ede542cb-f8ec1d4"
  Cache-Control: max-age=8640000, public
  Content-Type: image/gif
  Content-Length: 27566
  Date: Sun, 14 Jan 2018 21:15:48 GMT

Adding content via the REST interface

Submitting some content to the REST-ful interface, also requires the user to POST some content with a specified name.

  $ curl --request POST \
         --header "content-type: application/octet-stream" \
         --data-binary "@some.gif" \
         http://localhost:8080/api/v1/some.gif
  {
    "identifier" : "ede542cb-f8ec1d4",
    "length" : 27566,
    "type" : "image/gif",
    "suffix" : "gif",
    "uri" : "http://localhost:8080/ede542cb-f8ec1d4.gif"
  }

The response is a small JSON object, which provides the user with information about the content entry.

Content entry resources can also be queried on the REST-ful API, by using the identifier.

  $ curl http://localhost:8080/api/v1/ede542cb-f8ec1d4
  {
    "identifier" : "ede542cb-f8ec1d4",
    "length" : 27566,
    "type" : "image/gif",
    "suffix" : "gif",
    "uri" : "http://localhost:8080/ede542cb-f8ec1d4.gif"
  }

The content entry resource property uri can then be used to access the actual data.

Adding content through the drop-box

Directly under the Contessa base-dir, the folder dropbox is created, in order to provide support to manually add content.

By giving users access to this directory, they may drop in content files and have Contessa repond with information about the added entry. We start Contessa with the property -Dcontessa.base-dir=data/.

  $ ls -la data/dropbox/
  .
  ..
  $ cp some.gif data/dropbox/
  $ ls -la data/dropbox/
  .
  ..
  some.gif

(some seconds later)

  $ ls -la data/dropbox/
  .
  ..
  some.gif___ede542cb-f8ec1d4.gif

The dropped file will be picked up by Contessa and handled. The response is then written back as a marker-file, which the user must take care of, and clean out manually. Any response marker-files will of course be ignored by Contessa.

Adding content over AMQP

If Contessa is started and the contessa.amqp.enabled=true property is set, it will start and connect to a RabbitMQ.

To add content entries over the message broker we need to publish a message with the upload routing key, naming the file with the header filename. We provide a reply_to for the response and add the content to the message body.

Sending the message

In the overview we now see that our queue me has received one message.

Received response

The response returned contains header fields with identifier, suffix and the media type. The body payload consists of the created media entity name.

Response content

In this small example we can now query the media over HTTP, either using the web or REST endpoints.

Request content

Design & Idea

The main intent is to have a simple content service, with a strict and minimal API surface. Users should be able to submit and retrieve, content files in some appropriate ways.

Contessa will provide a very rich configurable out-of-the-box solution, that offers a sensible and adaptive solution to business hosting of media content.

Extensible structure

The design goal is to provide a separation between the two most important sub-systems or tiers - the user interface or API and the storage backend or data repository.

Configurable data repository

Using a simple set of configurations, the storage of data can be controlled, and easily set up for local filestorage, SQL or NoSQL storage.

Each storage comes with a different set of capabilities and Contessa allows for an adaptable solution, that suites many different business goals.

Optional user interfaces

Accessing or uploading data can be made in several different ways. From plain HTTP or web to REST-ful APIs, file-system polling or message bus brokers, the feature-set is rich and very capable. This puts Contessa in a compatibility level of its own.

Development & Stack

The current aim and goal of Contessa is to ensure the best possible capabilities for a meda content storage - but also, to stay within the boundaries of a very well understood and capable technical stack.

Building on Java and Spring Boot, currently mean that we can leverage the knowledge and interest of a whole lof of developers. We believe these developers to also be great ambassadors for Contessa, if we can provide them with idiomatic, transparent and well thought out code.

Building & testing

Anyone should be able to join in, and as the project evolves we will provide more specific information. At the moment running the project should be as easy as starting the project using the shortcut in the Makefile:

> make start

There will be more documentation evolving inside the docs/ folder.

Happy hacking!

contessa's People

Contributors

olle avatar olleolleolle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

contessa's Issues

Future: Tool or more an API

Want to discuss this because of the idea behind. Currently contessa is useable as standalone Springboot Application which is wonderful. There is a nice and easy straight forward frontend already developed. Some of the available store implementations bring their own frontend for this, so what to do then?
Disable the other frontends or implement a sync?

AMQP-response, must include name for correlation

In the case of using AMQP for content upload, the current protocol dictates that the user will retrieve a response for the published content-upload, to the provided reply-to address. However, it is not clear, if the protocol only accounts for direct-reply or if it is possible to decouple the publisher and the consumer of the reply.

As it currently is implemented, the response contains too little information to be able to correlate it back to the client publishing the content i.e. the name of the content is missing. Adding that would at least make the response more specific to the client.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.