8 Upload a new applcation
matu6968 edited this page 2024-11-21 11:58:00 +01:00

To upload a new app:

HTTP request type: POST

Authorization required: Yes (Header: Bearer auth, key is located in .env file)

Endpoint: /uploadapp

Parameters required:

Multipart body:

1. metadata (JSON, everything is required except for appid):

  {
    "name": "App Market Manager",
    "appid": "784520453945",
    "ver": "1",
    "info": "thisisatestedit",
    "pub": "matu6968"
  }

2. file (required):
Specify to use a file.

Output:

If it is successful:

{
	"name": "App Market Manager",
	"ver": "1",
	"appid": "784520453945",
	"info": "thisisatestedit",
	"pub": "matu6968",
	"path": "/apps/files/App Market Manager_1.js"
}

Status code: 200

If there is no token specified in header:

{
	"error": "No authorization header"
}

Status code: 401

If there is a invalid token:

{
	"error": "Invalid token"
}

Status code: 401

If there is no file provided:

{
	"error": "No file provided"
}

Status code: 400

If there is invalid JSON metadata in the multipart body:

{
	"error": "Invalid metadata"
}

Status code: 400

If there is a problem while making a directory to the uploaded file: (likely cause is directory where the binary is located is set to read only)

{
	"error": "Failed to make directory"
}

Status code: 500

If there is a problem while saving apps.json onto the host or while saving the uploaded file: (likely cause is directory where the binary is located is set to read only)

{
	"error": "Failed to save file"
}

Status code: 500

If using a HTTP request other then POST:

{
	"error": "Method not allowed. Only POST is supported for this endpoint."
}

Status code: 405