Skip to content

Panel file upload document improvement #2

@Jovesong1

Description

@Jovesong1

📖 Documentation Improvement

📍 Location

Please specify which part of the documentation needs improvement:

  • Page URL: [Pterodactyl Panel API Documentation - File Upload Section]

  • Section: File Upload API Guide

  • Specific endpoint (if applicable): GET /api/client/servers/{server}/files/upload

🎯 Type of Improvement

Missing information

Unclear explanation

Outdated content

Missing code examples

Missing language examples

Formatting issues

Other: Inconsistent method/field documentation

💡 Suggested Improvement

Update the file upload API documentation to accurately reflect the two-step upload process, correct HTTP method usage, and proper form field naming to align with actual API behavior.

🔍 Current Content (if applicable)

The current documentation states:

  • Uses POST method for the /api/client/servers/{server}/files/upload endpoint

  • Specifies files[] as the form field name for file uploads

  • Omits any mention of temporary upload URLs

  • Provides code examples that directly POST files to the endpoint

Example snippet from current documentation:

response = requests.post(f'https://your-panel.com/api/client/servers/{server\_id}/files/upload',

                        files={'files\[]': open('/path/to/local/file.txt', 'rb')}, 

                        data={'directory': '/'}, 

                        headers=headers)

✨ Proposed Content

Updated Endpoint Description:

The /api/client/servers/{server}/files/upload endpoint uses a two-step process:

  1. Step 1: Send a GET request to retrieve a temporary signed upload URL

  2. Step 2: Use the temporary URL to send a POST request with your file data

Corrected Code Example (Python):

import requests

server\_id = 'd3aac109'

headers = {

    'Authorization': 'Bearer ptlc\_YOUR\_API\_KEY',

    'Accept': 'Application/vnd.pterodactyl.v1+json'

}

\# Step 1: Get temporary upload URL

response = requests.get(

    f'https://your-panel.com/api/client/servers/{server\_id}/files/upload',

    headers=headers

)

upload\_data = response.json()

temporary\_upload\_url = upload\_data\['attributes']\['url']

\# Step 2: Upload file using temporary URL

files = {

    'files': open('/path/to/local/file.txt', 'rb')  # Note: Correct field name is 'files'

}

upload\_response = requests.post(temporary\_upload\_url, files=files)

if upload\_response.status\_code in (200, 201):

    print('File uploaded successfully')

Additional Notes:

  • The temporary upload URL has an expiration time (typically 15-30 minutes)

  • Use files as the form field name (not files[])

  • Do not include the original Authorization header when using the temporary URL

  • Follow the same two-step pattern for all programming languages

🎁 Additional Value

This improvement will:

  • Reduce developer frustration from following incorrect examples

  • Eliminate common errors like 405 Method Not Allowed and 400 No Files Found

  • Provide a clear, working implementation path for all users

  • Save development time by aligning documentation with actual API behavior

  • Prevent confusion about authentication flow with temporary URLs

📋 Additional Context

Developers following the current documentation encounter:

  • 405 Method Not Allowed errors when using POST directly to the endpoint

  • 400 No files were found errors when using the files[] field name

  • Confusion about authentication when moving to the temporary URL

The proposed changes resolve these issues by documenting the actual API workflow discovered through testing and error resolution.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions