Session Manager is a Node.js application that allows users to upload .zip
files, retrieve them using an access key, and manage session data. The uploaded files are stored temporarily and can be accessed within a specified time frame. This project also includes functionality for downloading, extracting, and managing JSON files within the uploaded .zip
files.
- Upload
.zip
files containing JSON files. - Retrieve uploaded files using a unique access key.
- Automatically delete files after 48 hours.
- Download
.zip
files using the access key. - Extract downloaded
.zip
files and store JSON files in a specified folder.
- Node.js: JavaScript runtime for server-side programming.
- Express: Web framework for building APIs.
- Axios: Promise-based HTTP client for making requests.
- Archiver: Library for creating
.zip
files. - Unzipper: Library for extracting files from
.zip
archives. - fs-extra: Library for file system operations with additional methods.
-
Clone the repository:
git clone https://github.com/AstroX10/session-manager.git cd session-manager
-
Install dependencies:
npm install
-
Run the server:
npm start
Make sure the server is running on the specified port (default: 3000).
POST /upload
- Request Body: Form-data with a field named
zipfile
containing the.zip
file. - Response: Returns a JSON object containing a success message, access key, and expiration time.
Example Request:
curl -X POST -F "zipfile=@path/to/yourfile.zip" http://localhost:3000/upload
Response:
{
"message": "File uploaded successfully as session1",
"accessKey": "33f755b6-2c61-414f-bb8f-a895d60a940e",
"expiresIn": "48 hours"
}
GET /download/:accessKey
- Parameters:
accessKey
- The unique access key for the uploaded file. - Response: Returns the requested
.zip
file.
Example Request:
curl -O http://localhost:3000/download/33f755b6-2c61-414f-bb8f-a895d60a940e
GET /session/:accessKey
- Parameters:
accessKey
- The unique access key for the uploaded file. - Response: Returns session details including access key, file name, and timestamps.
Example Request:
curl http://localhost:3000/session/33f755b6-2c61-414f-bb8f-a895d60a940e
- Place your JSON files in the
auth
folder. - Run the test script to create a
.zip
file, upload it to the server, and download it using the access key.
Example Test Script (test/test.js
):
// Import necessary modules and set up the test script here...
- After downloading the
.zip
file, the script automatically extracts it into thesession
folder, placing all.json
files within that folder.
The application is designed to delete uploaded files after 48 hours. Ensure to manage the directory structure and files as per your needs.