Giter Club home page Giter Club logo

akanass / upload-file-with-chunks Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 2.48 MB

Project to show how to upload a file in the browser and send it fully or in several chunks to the server. It is an implementation of the "@akanass/rx-file-upload" library for the client part and of the "fastify-multipart" pluglin for the server part in NestJS.

License: MIT License

JavaScript 2.06% TypeScript 68.90% SCSS 7.86% Handlebars 19.23% Dockerfile 1.95%
browser file-upload chunked-uploads checksum rxjs7 stream formdata multipart-formdata multipart-uploads chunks

upload-file-with-chunks's Introduction

Upload Files With Chunks

Project to show how to upload a file in the browser and send it fully or in several chunks to the server.

It is an implementation of the "@akanass/rx-file-upload" library for the client part and of the "fastify-multipart" pluglin for the server part in NestJS.

NOTE: You must have a recent browser that supports ESM modules in order to run the application.

Installation

$> cd path/to/workspace
$> git clone https://github.com/akanass/upload-file-with-chunks.git | [email protected]:akanass/upload-file-with-chunks.git

Local

# install dependencies
$> yarn install | npm install

Docker

You don't have to do anything more.

Running the app

Once launched, the application will run on port 3000.

Local

# build
$> {yarn|npm} run build

# production mode
$> {yarn|npm} run start:prod

Docker

$> docker compose up -d

Configuration

You can change the configuration in default config file.

If for example you want to use your own API to receive the files you need to change the upload.api.fileEndpoint value to "http://mon-api.com".

Each time you change a configuration data, you will have to restart the application for the changes to be taken into account.

Local

# relaunch production mode
$ {yarn|npm} run start:prod

Docker

$ docker compose up --build -d

Application in details

Once your application is launched, you will first need to select the file to upload to your API:

rootCA

Once selected, you can choose upload options:

rootCA

If you choose to upload your files into chunks, you will be able to choose the size of each chunk using the associated slider.

If the value is equal to 0 then the default value of 1Mb will be taken into account.

rootCA

The second possible option is to add a sha256 encoded checksum for each file.

However, you should know that the larger the file, the longer the generation time will be, which will cause a delay before sending it to the API.

rootCA

Finally, you just have to click on the upload button and enjoy the magic of the library that will do everything for you:

rootCA

If you use our API to upload your files, the destination path will be indicated as you can see in the screenshot.

In the case of using the application in Docker, the files will be uploaded to the mounted directory docker_tmp_upload which is at the root of this project.

And of course, multiple file uploads are taken into account by the library:

rootCA

Implementation

If you want to see how the client implementation is going you can go here and for the server implementation here.

If you want to see what is exactly sent by the library to the server, you can go here.

License

This project is MIT licensed.

upload-file-with-chunks's People

Contributors

akanass avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

aimeiyijia

upload-file-with-chunks's Issues

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.