Skip to content

Image upload, storage and download microservice using Spring boot, MySQL and local storage. This service will be used for the final project of our Webservices course at IT-Högskolan, Gothenburg.

Patlenlix/image-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Storage Microservice

GitHub issues GitHub pull requests

Description

Image upload, storage and download microservice using Spring boot, MySQL and local storage. This service will be used for the final project of our Webservices course at IT-Högskolan, Gothenburg.

Deployment

  1. Create network:
    docker network create net
  2. Create volumes:
    docker volume create db-storage
    docker volume create file-storage
  3. Start consul:
    docker run -d -p 8500:8500 -p 8600:8600/udp --name=consul --network=net consul agent -server -ui -node=server-1 -bootstrap-expect=1 -client='0.0.0.0'
  4. Add config file to consul
    1. Open Consul UI: http://localhost:8500
    2. Go to Key/Value
    3. Create the following folder structure: config/image-service/
    4. Create a file named: data (.yml)
    5. Add the following YML data:
spring:
   servlet:
      multipart:
         max-file-size: 10MB
         max-request-size: 10MB
   cloud:
      consul:
         discovery:
            register: true
            prefer-ip-address: true
            instance-id: ${spring.application.name}:${spring.cloud.client.hostname}:${random.int[1,999999]}
         host: consul
   jpa:
      hibernate:
         ddl-auto: update
   datasource:
      url: jdbc:mysql://image-database:3306/images
      username: user
      password: password
server:
   port: 8080
  1. Start database:
    docker run -d --name image-database -e MYSQL_ROOT_PASSWORD=root -e 'MYSQL_ROOT_HOST=%' -e MYSQL_DATABASE=images -e MYSQL_USER=user -e MYSQL_PASSWORD=password -p 3306:3306 --network=net -v=db-storage mysql:latest
  2. Start application:
    docker run -d --name image-service -p 8080:8080 --network=net -v=file-storage ghcr.io/patlenlix/image-storage:latest

Endpoints

HTTP-verb URL BODY PRODUCES HEADER Info
POST /images A MultipartFile with the name "multipartFile" and the mediatype set to any Content-Type: multipart/form-data
optional: (URI: uri used to reach endpoint)
Uploads an image
GET /images/{imageId} An image file Downloads an image with id = {imageId}

About

Image upload, storage and download microservice using Spring boot, MySQL and local storage. This service will be used for the final project of our Webservices course at IT-Högskolan, Gothenburg.

Topics

Resources

Stars

Watchers

Forks