Sign inSign up

paliari/upload-service

By paliari

Updated over 3 years ago

Image
0

1.6K

paliari/upload-service repository overview

Upload microservice

A lightweight upload microservice


Environments:
NameRequiredExample
BASE_URLyeshttp://your-base-url.com
SECRET_KEYno123
SECRET_JWTnoawesome-secret
BASE_URL

Your hosting will be concatenated to the top of the directory to access the files.

SECRET_KEY

Token for upload authentication, if not informed upload will be public.

In request send header Secret-Key

SECRET_JWT

Secret key for JWT encryptor

Volumes
NameRequired
/storageyes
/storage

Volume used to save files


Run with Docker

.env

BASE_URL=http://localhost:3000
SECRET_KEY=123
SECRET_JWT=my-secret

docker-compose.yml

version: '3.7'

services:
  app:
    image: paliari/upload-service
    ports:
      - 3000:3000
    volumes:
      - storage:/storage
    env_file: .env

volumes:
  storage:

HTTP API
GET /health

Route for check health

Content-Type: application/json

  • Response 200 (application/json)
      {
        "version": "1.0.0",
        "applicationName": "Upload Service"
      }
    
GET /jwt

Route for get a jwt token to authenticate upload. Send this token in Authorization header.

Content-Type: application/json

  • Request

Headers

NameRequiredType
Secret-Keyyesstring
  • Response 200 (application/json)
      {
        "token": "jwt.example.token"
      }
    
POST /

Route for file uploads, if authenticated, send JWT token in Authorization header

Content-Type: multipart/form-data

  • Request

Attributes

NameRequiredType
fileyesBlob

Headers

NameRequired
AuthorizationIf Secret-Key is defined
  • Response 201 (application/json)
      {
        "url": "http://your-base-url.com/storage/2019/12/03/123e4567-e89b-12d3-a456-426655440000.jpeg"
      }
    

Development

Define environments

cp .env.example .env

Run tests

yarn docker:test

Start development server

docker-compose up

Tag summary

Content type

Image

Digest

sha256:7ad15ba80

Size

30.1 MB

Last updated

over 3 years ago

docker pull paliari/upload-service