Giter Site home page Giter Site logo

fossabot / file-storage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mykelangelo/file-storage

0.0 1.0 0.0 89 KB

An application that allows us to store files in the cloud, categorize them with tags and search through them.

License: GNU General Public License v3.0

Java 100.00%

file-storage's Introduction

Dependabot Status

File Storage

FOSSA Status

How to only build (with db shutdown)

  1. open root dir ("file-storage")
  2. in terminal, run "./mvnw clean docker:start install docker:stop" (no Maven or Docker needed)

How to build and run (without db shutdown)

  1. open root dir ("file-storage") in a different terminal window
  2. in terminal, run "./mvnw clean docker:start install" (no Maven or Docker needed)
  3. open target dir ("cd target")
  4. run with command "java -jar file-storage-0.0.1-SNAPSHOT.jar"

How to check if app is up

  1. In browser open "localhost:8080/health/ping", and you should see "pong"

How to shut down db

  1. open root dir ("file-storage")
  2. in terminal, run "./mvnw docker:stop" (no Maven or Docker needed)

How to run integration tests (v1: with docker-compose)

  1. open root dir ("file-storage")
  2. install docker-compose (for Mac: "brew install docker-compose")
  3. in terminal, run "docker-compose up"
  4. run tests
  5. in terminal, run "docker-compose down"

How to run integration tests (v2: without docker-compose)

  1. open root dir ("file-storage")
  2. in terminal, run "./mvnw clean docker:start install" (no Maven or Docker needed)
  3. open target dir ("cd target")
  4. in terminal, run "java -jar file-storage-0.0.1-SNAPSHOT.jar"
  5. run tests
  6. in terminal, run "./mvnw docker:stop" (no Maven or Docker needed)

Description

File Storage REST service

Let's imagine we are developing an application that allows us to store files in the cloud, categorize them with tags and search through them.

In this test assignment let's implement the smaller subset of the described functionality. We won't store the actual file content, only their name and size at the moment.

Design a web-service (REST) with an interface described below.

1. Upload

POST /file

{ "name": "file_name.ext" "size" : 121231 # size in bytes }

returns status 200 and body: { "ID": "unique file ID" }

or status 400 with error if one of the field is absent or has incorrect value (like negative file size) { "success": false, "error": "error description" }

2. Delete file

DELETE /file/{ID}

returns status 200 and body {"success": true}

or 404 and body { "success": false, "error": "file not found" }

3. Assign tags to file

POST /file/{ID}/tags

["tag1", "tag2", "tag3"]

returns status 200 and body {"success": true}

4. Remove tags from file

DELETE /file/{ID}/tags

["tag1", "tag3"]

returns status 200 if all OK and body {"success": true}

returns status 400 if one of the tags is not present on the file and body { "success": false, "error": "tag not found on file" }

5. List files with pagination optionally filtered by tags

GET /file?tags=tag1,tag2,tag3&page=2&size=3

Here:

  • tags - [optional] list of tags to filter by. Only files containing ALL of supplied tags should return. If tags parameter is omitted - don't apply tags - filtering i.e. return all files.
  • page - [optional] the 0-based parameter for paging. If not provided use 0 (the first page)
  • size - [optional] the page size parameter. If not passed use default value 10.

returns status 200 with body:

{
   "total": 25,
   "page": [
       {
          "id": "ID1",
          "name": "presentation.pdf",
          "size": 123123,
          "tags": ["work"]
       },
       {
          "id": "ID2",
          "name": "file.mp3",
          "size": 123123,
          "tags": ["audio", "jazz"]
       },
       {
          "id": "ID3",
          "name": "film.mp4",
          "size": 123123,
          "tags": ["video"]
       }
   ]
}

Here:

  • total - the total amount of files that satisfy the provided list of tags or total files count if no tags provided
  • page - the actual records to show on the current page.

Bonus

These items are not obligatory for implementation but if you have time and desire - you could work on them as well once you complete the main assignment. Would be good additional points for your candidature.

  • at the upload automatically add tag "audio" / "video" / "document" / "image" etc. based on extension
  • in the listing endpoint handle optional parameter q that will apply a search over file name. I.e. if you pass GET /file?q=aaa this will yield files "aaaaaaa.txt", "bbbb aaa ccc.zip", "AaAA.mp3" etc.
  • Nice to have some unit / integration tests added.

Requirements

  • As a data storage, please use Elasticsearch.
  • As a main framework please use Spring Boot.
  • Please use Java 11 and Maven for this project
  • Use GitHub, GitLab for your development - at your choice. You will send a link to the final repo with code for check.
  • Provide README.md file with a description of the project, how to run it etc.
  • Try to use best code practices, apply commenting on code when necessary.
  • The recommended implementation time for this project is 2 days.

License

FOSSA Status

file-storage's People

Contributors

dependabot[bot] avatar fossabot avatar mykelangelo 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.