GithubHelp home page GithubHelp logo

danielshiplett / jhipster_uploader Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 5.0 3.03 MB

An example of how to get JHipster and ng-flow to play together.

JavaScript 24.32% Java 47.04% HTML 22.16% ApacheConf 5.02% CSS 0.75% Scala 0.72%

jhipster_uploader's Introduction

README for uploader_example

Introduction

This application is to demonstrate how to connect ng-flow (the file uploader) to a JHipster-based application.

This example will implement a very simple file uploader resource/service to handle the required functions of the ng-flow client library. It will save all uploaded chunks/files into the src/main/webapp/assets directory.

Usage

Run the application with 'mvn spring-boot:run'

Go to the site.

Log in as user/user.

See the new Navbar item for 'Uploader' and click it.

Upload a file.

Description (or what you need to know)

The basic idea is that the ng-flow client will get a new flow identifier at the start of a flow. We have a function to handle this that returns a random UUID.

Next the client will test if a chunk is already uploaded. We return 502 if it hasn't. This is some of the weirdness with the HTTP codes that I haven't quite figured out yet. I think this could be handled better.

Assuming the test returns the 502 then the client will do a MultiPart POST with the data for the next chunk. We take this and save off the chunk.

We track which chunks we have received and which ones we haven't.

When the last chunk arrives we will merge them back into the original file and delete the chunks.

Client Setup

Beyond the bower installation, you will also need to include the 'flow' service in the Angular app.js file and add the addition flowFileProvider configuration section.

We are configured to only allow one file upload at a time.

We also specify the location of the unqiue identifier function.

Client Usage

See the app/uploader client code for how to use the ng-flow library. Basically just add the flow directives at the top.

You can also do fancy things like track the upload progress with a progress bar and display info about the upload after it is done.

Upload Domain Object

A simple object that tracks the original file name from the client along with expected chunks and file size.

Several things to note:

  • LocalDate should really be LocalDateTime but there is no JHipster support
  • Manually added List because there is no JHipster support
  • ID is a String but we always put a UUID.toString there

UploadServiceImpl

The most basic I could think of was to save locally. A better implementation would put the file somewhere that they could be retrieved again. And probably not store them in the project path.

UploadResource

Basically just obeys the requirements for the flowJS library that underpins the ng-flow library.

jhipster_uploader's People

Contributors

danielshiplett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.