f-send

Send a file to server

Usage no npm install needed!

<script type="module">
  import fSend from 'https://cdn.skypack.dev/f-send';
</script>

README

Send a file to server

Install:

    npm i f-send --save

Usage:

  1. import into service o component
import { fileSend } from "fileSend";
  1. inject in the constructor
construct( private _fs:fileSend  ){}
  1. usage:
    _fs.send( File, "http://localhost:4002/upload" , "PUT" ,"imagen", true  )
            .then( r =>{
                console.log(r) // server response 
            });

'State' property returns the state an XMLHttpRequest

Value Description
0 Client has been created. open() not called yet.
1 XmlHttpRequest.open() has been called.
2 XmlHttpRequest.send() has been called, and headers and status are available.
3 Downloading; responseText holds partial data.
4 The operation is complete.
    let percentage:number;
    percentage = _fs.State * 25;
    // 1 => 25% 
    // 2 => 50% 
    // 3 => 75%
    // 4 => 100%