CloudStorage is a small pet project written in Node.js. This project enables users to upload and download files from a remote server. The server uses the local disk for storage. In this project, the issue of concurrent access to files is solved using the npm module "mutex-async".
- Retrieving a list of files from the server in JSON format
- Uploading file(s) to the server using form-data
- Downloading a specific file from the server
- Deleting a specific file or an entire folder from the server
NOTE: Installation requires Node.js v19.9.0 or higher and npm v9.6.3 or higher.
- Download or clone the repository to your computer:
$ git clone https://github.com/DmitryMezhevich/UploadFiles.git
- Open the project folder in the terminal.
- Install all external npm dependencies:
$ npm install
- Start the application:
$ npm start
The CloudStorage application has also been deployed on a remote server as a pet project. You can make requests to the remote API using the following URL:
url https://cloudstorage-02ii.onrender.com
IMPORTANT: The storage capacity of the remote server is limited as I'm using a free subscription for my pet project.
The maximum size of an uploaded file should not exceed 4 GB (if you plan to upload large files, I recommend installing the application on your local computer).
For making requests to the API, it is recommended to use Postman. Note: If you want to use the demo version, make sure to replace "localhost:3000/" with the "https://cloudstorage-02ii.onrender.com" in all requests.
- Get a list of files in JSON format:
GET localhost:3000/files-management/orders
Example of a response from the server in JSON format:
[
{
"orderID": "100",
"type": "directory",
"children": [
{
"name": "1.png",
"type": "file"
}
]
}
]
- Uploading file(s) to the server using form-data:
POST localhost:3000/files-management/orders/{orderID}
Where orderID is the identification number of the folder where the file(s) will be stored. In the form-data, it is mandatory to specify the key under which the uploaded file is located. Example response from the server in JSON format:
{
"description": "File(-s) was upload!"
}
- Downloading a specific file:
GET localhost:3000/files-management/orders/{orderID}/files/{fileID}
Where orderID is the identification number of the folder where the file is located, and fileID is the name of the file.
Note: You can obtain the list of available files by making a request to retrieve the list of files: GET localhost:3000/API/listFiles.
The response will be the downloaded file.
- Deleting a specific file or an entire folder:
DELETE localhost:3000/files-management/orders/{orderID}/files/{fileID}
DELETE localhost:3000/files-management/orders/{orderID}
Where orderID is the identification number of the folder where the file is located, and fileID is the name of the file.
Example of a response from the server in JSON format:
{
"descripthin": "File: '1.png' has been remove!"
}
- express
- async-mutex
- formidable
- path
- fs
- fs-extra