Coder Social home page Coder Social logo

filemanager's Introduction

Simple File Manager

This project was built using Quarkus, MySQL and storing binary files in local folders.

Build GitHub

Requirements

  • Java 11+
  • Maven 3.8+
  • Docker
  • Docker Compose

Development Mode

This mode can be used as quick start and for evaluation purposes.

  • Execute MySQL container: docker-compose up mysql-db
  • Run ./mvnw quarkus:dev for debug mode ./mvnw quarkus:dev -Ddebug

Sample of requests:

This application uses the API First principles, you may import the file openapi.yaml (OpenAPI v3) into Postman or other tools. You may also open Swagger UI (http://localhost:8080/q/swagger-ui/) in development mode.

Upload a new file

-------------- REQUEST  --------------
curl --location --request POST 'http://localhost:8080/files' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"/home/user/file.jpg"' \
--form 'fileName="file.jpg"'

-------------- RESPONSE  --------------
{
    "id": "df9b8e0f-c30f-4530-8677-6696f5d504b0",
    "originalFileName": "file.jpg",
    "lastVersion": 1,
    "size": 5464266,
    "checksum": "d4f9bfe4ad7914949776dacd2a5b309d336ae4e8d480df32c9c4c826f14e4c5f",
    "createdAt": "2021-11-16T23:02:45.775816",
    "updatedAt": "2021-11-16T23:02:45.775829"
}

The new upload will generate a new ID in the response which will be used in the next requests. In the example above, the ID is df9b8e0f-c30f-4530-8677-6696f5d504b0

Get file metadata

-------------- REQUEST  --------------
curl --location --request GET 'http://localhost:8080/files/df9b8e0f-c30f-4530-8677-6696f5d504b0' 

-------------- RESPONSE  --------------
{
    "id": "df9b8e0f-c30f-4530-8677-6696f5d504b0",
    "originalFileName": "file.jpg",
    "lastVersion": 1,
    "size": 5464266,
    "checksum": "d4f9bfe4ad7914949776dacd2a5b309d336ae4e8d480df32c9c4c826f14e4c5f",
    "createdAt": "2021-11-16T23:02:45.775816",
    "updatedAt": "2021-11-16T23:02:45.775829"
}

Upload another version of file

-------------- REQUEST  --------------
curl --location --request PUT 'http://localhost:8080/files/df9b8e0f-c30f-4530-8677-6696f5d504b0' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"/home/user/file2.jpg"' 
--form 'fileName="file2.jpg"'

-------------- RESPONSE  --------------
{
    "id": "fd2cdb87-84b4-4228-923b-eec505838669",
    "originalFileName": "file2.jpg",
    "lastVersion": 2,
    "size": 5464266,
    "checksum": "d4f9bfe4ad7914949776dacd2a5b309d336ae4e8d480df32c9c4c826f14e4c5f",
    "createdAt": "2021-11-16T23:16:10.63632",
    "updatedAt": "2021-11-16T23:16:10.636388"
}

Download file

-------------- REQUEST  --------------
curl --location --request GET 'http://localhost:8080/files/df9b8e0f-c30f-4530-8677-6696f5d504b0/file?version=1' --output file.jpg 

Delete file and all their versions

-------------- REQUEST  --------------
curl --location --request GET 'http://localhost:8080/files/df9b8e0f-c30f-4530-8677-6696f5d504b0

Running the project

  • Execute a build: ./mvnw package
  • Build the container: docker-compose build
  • Run project: docker-compose up

filemanager's People

Watchers

OTONIEL DA SILVA 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.