Skip to content

kevinraz/Node-File-Upload-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js File Upload Example

Purpose

Creates an HTTP server to listen on user specified port. API includes a RESTful file upload and download utility.

How to Install/Use

Installation is as easy as running:

git clone git@github.com:kevinraz/Node-File-Upload-Example.git

Start service:

cd /projects/Node-File-Upload-Example/
npm install
node index.js
Open URL: http://localhost:18881/

Task 1

Create a basic node.js program that provides a HTTP service listening on port 18881 which allows a HTTP client to create a new file object, then upload and download the file data for the file object.

The service should meet the following minimum requirements:

  • The following API should be used:
    • POST /files
      • The request should allow a client to create a new file object and set its name and extension properties, but not upload file data.
      • The response should provide the new file’s fileId.
    • GET /files/{fileId}
      • The response should return the name and extension properties associated with withfile object.
    • PUT /files/{fileId}/data
      • The request should upload the file data for the existing file object.
      • The request header Content-Type should be set appropriately.
    • GET /files/{fileId}/data
      • The response should provide the file data for the existing file object.
      • The response header Content-Type should be set appropriately.
  • File data should be transferred directly in the request and response bodies.
  • Use JSON for any text data in request and response bodies.
  • Each request should use a custom HTTP header to pass in a client’s API key.
    • The API key need only be checked for existence in the service.
  • File data should be stored on the local disk in the PUT request.
  • File data should be retrieved from the local disk in the GET request.
  • You may choose how the service stores file object properties name and extension.

Task 2

Create a basic node.js program that acts as a client to the HTTP service you created above. The client be able to:

  • For each file in a specified directory:
    • Send an HTTP request to create a new file object on the server, specifying the name and extension of the current local file.
    • Send an HTTP request to upload the local file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors