Developer Documentation - TheCoolcraft11/ScreenshotUploader GitHub Wiki

Developer Docs

This guide will walk you through the steps to integrate your own web server with the Screenshot Uploader Mod. The mod allows you to upload and manage screenshots through a custom server, as well as display a gallery of uploaded images.

1. Required Endpoints

To fully integrate your web server with the Screenshot Uploader Mod, you need to create the following two endpoints:

1.1 Upload Endpoint (Multipart Form Data)

This endpoint will receive screenshot files uploaded from the mod. It should accept multipart data, where the image file is uploaded along with a jsonData object containing metadata about the screenshot. It has to send a response with a json object containing url: the public url of the screenshot, gallery: the public gallery url(if a gallery is present), success: true/false if the screenshot was saved successfully, message: "Status message"

  • HTTP Method: POST
  • Content-Type: multipart/form-data
  • Request Body:
    • The image file (sent as part of the multipart form data).
    • jsonData (sent as a separate field in the request). This object contains the following properties: metadata: Additional metadata about the screenshot (e.g. user, coordinates, world name, etc.). Example for jsonData:
{
"username": "SomePlayer",
"uuid": "00000000-0000-0000-0000-000000000000",
"accountType": "MSN",
"world_name": "minecraft:overworld",
"coordinates": "X: -592, Y: 71, Z: -485",
"biome": "Plains",
"facing_direction": "south",
"dimension": "minecraft:overworld",
"player_state": "Flying: false, Sneaking: false, Gliding: false",
"chunk_info": "Chunk: [-37, -31]",
"entities_info": "Loaded Entities: 136",
"world_info": "Time: 2618506, Weather: Clear, Difficulty: easy",
"server_address": "localhost",
"client_settings": "Graphics: fancy, V-Sync: true, Fullscreen: true, Language: en_us",
"system_info": "OS: Windows 11 10.0 (amd64), Java: 21.0.5",
"current_time": "1737912739463"
}

Example for the response:

{
  "url": "http://your-public-address/screenshots/screenshot-Player960_1737912740345.png",
  "success": true,
  "gallery": "http://your-public-address/gallery",
  "message": "Upload successful"
}

1.2 List Screenshots Endpoint (JSON Response)

This endpoint will return a list of all uploaded screenshots in JSON format. Each screenshot object should include the following data:

  • filename: The name of the screenshot file.

  • url: The publicly accessible URL where the screenshot can be viewed or downloaded.

  • username: The username of the player who uploaded the screenshot.

  • date: The date and time when the screenshot was uploaded.

  • metadata: The additional metadata about the screenshot (same as provided in jsonData).

  • HTTP Method: GET

  • Content-Type: application/json

Screenshot Object Example:

{
"filename": "screenshot-Player917_1739451883251.png",
"url": "http://localhost:4567/screenshots/screenshot-Player917_1739451883251.png",
"username": "Player917",
"date": 1739451883755,
"metaData": {
    "username": "Player917",
    "uuid": "99c5cfd7-706e-3304-b77d-748a9e6aeb44",
    "accountType": "LEGACY",
    "world_name": "minecraft:overworld",
    "coordinates": "X: -589, Y: 71, Z: -488",
    "biome": "Plains",
    "facing_direction": "south",
    "dimension": "minecraft:overworld",
    "player_state": "Flying: false, Sneaking: false, Gliding: false",
    "chunk_info": "Chunk: [-37, -31]",
    "entities_info": "Loaded Entities: 128",
    "world_info": "Time: 4668314, Weather: Clear, Difficulty: easy",
    "server_address": "localhost",
    "client_settings": "Graphics: fancy, V-Sync: true, Fullscreen: true, Language: en_us",
    "system_info": "OS: Windows 11 10.0 (amd64), Java: 21.0.6",
    "current_time": "1739451881713"
    }
}

2. Optional: Web Gallery Page

You can also create an optional web page to display all screenshots in a gallery format. This page can retrieve data from the /screenshots endpoint and showcase each screenshot along with its associated metadata. Alternatively, you could use a templating engine like EJS to dynamically render and display the screenshots within your gallery