Conversation
Deploying pterodactyl-api-docs-public with
|
| Latest commit: |
00f0a53
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fa324c4a.pterodactyl-api-docs-public.pages.dev |
| Branch Preview URL: | https://2-panel-file-upload-document.pterodactyl-api-docs-public.pages.dev |
…rovide alternative methods
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the file upload documentation for the Pterodactyl v1 API by documenting the correct two-step process instead of the incorrect single-step approach. The documentation now properly explains that file uploads require first obtaining a signed upload URL, then using that URL to upload files.
Key Changes:
- Updated file upload process from single-step to correct two-step approach
- Added comprehensive code examples in 9 programming languages
- Included multiple file upload examples and important implementation notes
| files = {'files': f} | ||
| data = {'directory': directory} | ||
| upload_response = requests.post(signed_url, files=files, data=data) | ||
|
|
There was a problem hiding this comment.
The documentation should clarify what each status code means. Status code 200 typically indicates success with response body, while 204 indicates success with no content. Consider adding a comment explaining when each status code is returned.
| # 200 = Success with response body, 204 = Success with no content |
|
|
||
| ### Important Notes | ||
|
|
||
| - **Signed URL Validity**: The signed URL is valid for 15 minutes (verified from source code) |
There was a problem hiding this comment.
[nitpick] While the 15-minute validity is useful information, referencing 'verified from source code' in user-facing documentation is unusual. Consider rephrasing to simply state the validity period without the verification note, or cite official documentation instead.
| - **Signed URL Validity**: The signed URL is valid for 15 minutes (verified from source code) | |
| - **Signed URL Validity**: The signed URL is valid for 15 minutes |
| break; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
The PHP example shows uploading files one by one in a loop, but this contradicts the earlier statement that 'Maximum files per request' is 10 files. This approach would result in multiple separate requests rather than one request with multiple files. Consider clarifying this discrepancy or providing a working multi-file upload example for PHP.
| // Option 1: Upload multiple files in a single request (recommended) | |
| $postFields = ['directory' => $directory]; | |
| foreach ($filePaths as $idx => $filePath) { | |
| $postFields["files[$idx]"] = new CURLFile($filePath); | |
| } | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $signedUrl); | |
| curl_setopt($ch, CURLOPT_POST, true); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| $uploadResponse = curl_exec($ch); | |
| $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| curl_close($ch); | |
| if ($httpCode !== 200 && $httpCode !== 204) { | |
| echo "Failed to upload files.\\n"; | |
| } |
| file_handle.close() | ||
|
|
||
| if upload_response.status_code in [200, 204]: | ||
| print('Multiple files uploaded successfully')`, |
There was a problem hiding this comment.
The Python example opens multiple files but only closes them after the upload request. If the upload request fails or throws an exception, the file handles may not be closed properly. Consider using a context manager or try/finally block to ensure proper cleanup.
| print('Multiple files uploaded successfully')`, | |
| import contextlib | |
| with contextlib.ExitStack() as stack: | |
| files = [] | |
| for file_path in file_paths: | |
| file_handle = stack.enter_context(open(file_path, 'rb')) | |
| files.append(('files', file_handle)) | |
| data = {'directory': directory} | |
| upload_response = requests.post(signed_url, files=files, data=data) | |
| if upload_response.status_code in [200, 204]: | |
| print('Multiple files uploaded successfully')`, |
📋 Pull Request Description
🎯 Type of Change
📖 What does this PR do?
The previous documentation for the file upload API call for v1 was incorrect. This fixes that by introducing the actual two step process currently present in Pterodactyl v1.
🔍 Related Issue
Closes #2
📍 Changes Made
🧪 Testing
npm run build)📋 Checklist