This Node.js application serves as a simple API for saving files. It allows users to send a POST request to the /saveFile
endpoint with the necessary data, and the server will save the provided file in the logs
directory.
Example: You can use this for save your Discord chat transcripts!
- Node.js installed on your machine.
- Clone the repository:
git clone https://github.com/nikit0/save-file-api.git
- Install dependencies:
npm install
- Start the server:
npm start
The server will be running on http://localhost:3000 by default.
Endpoint
- POST
/saveFile
Request Payload
- JSON object with the following properties:
Parameters | Types | Description |
---|---|---|
fileName |
(string) | The name of the file to be saved. |
buffer |
(string) | The content of the file in a buffer. |
Example Request
curl -X POST -H "Content-Type: application/json" -d '{"fileName": "file.txt", "buffer": "Hello, this is a Save File API!"}' http://localhost:3000/saveFile
Response
- If the file is successfully saved:
{
"status": "100"
}
- If there is an issue with the request:
{
"status": "500"
}
File saved using the API can be accessed directly via the /logs path on the server. Example: http://localhost:3000/logs/file.txt
- If a request is made to an undefined route:
- Response: Status 400 with the message "404 Error: Page not found!"
This project is licensed under the MIT License - see the LICENSE file for details.