GithubHelp home page GithubHelp logo

mikfreedman / blobber Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 60 KB

A very very limited blob store (proof of concept)

License: MIT License

Kotlin 100.00%
spring-boot mysql blob-store cloud-foundry cloud-foundry-application

blobber's Introduction

Blobber

This project is a very simple implementation of a blob store http service that is backed by MySQL

It leverages Spring Auto-Reconfiguration to know how to run "in the cloud". That is, it expects a bound database service to work correctly.

No considerations have been made for performance.

Deployment on Cloud Foundry

Security

Note I in no way recommend deploying this service to the public internet as it is currently designed. This service is designed as a workaround for when you are unwilling or unable to leverage a cloud file store (e.g. AWS S3).

As written, it is intended to be deployed on Cloud Foundry instances that exist behind a firewall.

Aside from the API Key mentioned here, no real considerations have been made to secure the application.

Ensure that BLOBBER_API_KEY is set, clients of this store should provide the same key as a header (X-API-KEY) when posting files.

cf set-env [application-name] BLOBBER_API_KEY [inscrutable-key]

Database

Initialize your database with the following schema

CREATE TABLE files 
  ( 
     id            VARCHAR(255), 
     content_bytes LONGBLOB, 
     content_type  VARCHAR(255) 
  ); 

I use the this cf cli plugin: andreasf/cf-mysql-plugin to easily connect to my bound database.

Push It

./gradlew build
cf push [application-name] -p build/libs/blobber-0.0.1-SNAPSHOT.jar

Usage

Upload a file like so

curl -X POST \
  http://[application-name].cfapps.io/files \
  -H 'content-type: multipart/form-data' \
  -H 'x-api-key: [inscrutable-key]' \
  -F file=@[path-to-your-file].png

Expected Response

Currently the service will return a UUID which you can use to construct a public URL

{
  "uuid": "some-fancy-uuid" 
}

becomes:

http://[application-name].cfapps.io/files/some-fancy-uuid

Testing

./gradlew test

blobber's People

Stargazers

 avatar  avatar

Watchers

 avatar

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.