mirror of
https://github.com/phantomptr/ps5upload.git
synced 2026-10-22 11:53:22 -05:00
When PS5Upload Files is opened from a phone or PC on the LAN (not from the console itself), Files offers Upload here and Download. Upload: POST /api/upload/begin checks path policy, the folder, an existing name (409 exists / not_a_file) and free space (507) before any byte is sent and reserves the one upload slot (409 busy; forgotten after 30 s); the bytes follow as POST /api/upload/data?id= (streamed, idle timeout 20 s), written to a temp file beside the target and renamed only when complete, so a cancel or a dropped client leaves nothing. /api/upload/cancel frees a reservation. The page sends files (or a folder, where the browser can pick one) one at a time with progress, Skip this file / Stop, and Skip / Keep both / Replace for names already there. Download: /api/download/begin hands out a /dl/<ticket>/<name> link (128-bit, for that item only, 60 s after last use) that the browser saves with a plain navigation: a file with Content-Length and Range, a folder as a .tar streamed as it is read (pax for long names and > 8 GiB sizes, links and other mounts left out). One download at a time; trust store and its ancestors refused. Measured on the Phat (13.60, LAN), 1 GiB: upload 66-75 MiB/s, download 111 MiB/s, folder .tar 101 MiB/s. Strings in all 21 locales. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RxCGb8Asp1A1AQYiv1kbgS
47 lines
2.5 KiB
C
47 lines
2.5 KiB
C
/* The console web UI's JSON API (Home, Files): the webui_route_fn main.c hands to webui_start.
|
|
*
|
|
* Every route is POST with a JSON body and adapts it to a method the helper already serves
|
|
* (management through mgmt_rpc_dispatch, the data layer through ava1_data_rpc, both reached the
|
|
* way the AVA1 server reaches them), under one fixed identity: the console page owns the jobs it
|
|
* starts as "ps5upload-console-webui". The route table in webui_api.c is the allowlist: any other
|
|
* path answers 404, a known path with another method 405.
|
|
*
|
|
* POST /api/input-log {"events":["<line>",...]} is the one route that reaches no helper method: it
|
|
* appends the page's controller-input measurements to WEBUI_INPUTLOG_PATH (webui_inputlog.h),
|
|
* bodies over WEBUI_INPUTLOG_BODY_MAX answer 413, calls closer than 500 ms apart 429.
|
|
*
|
|
* Three GET routes sit outside the table: GET / serves the embedded page (webui_page.h),
|
|
* GET /api/token answers {"token":"<hex>"} and GET /strings/<lang>.json one language's embedded
|
|
* strings (webui_strings.h; an id not in that table answers 404), all after the server's
|
|
* Host/Origin check only. */
|
|
#ifndef PS5UPLOAD_WEBUI_API_H
|
|
#define PS5UPLOAD_WEBUI_API_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "webui_http.h"
|
|
#include "webui_settings.h"
|
|
|
|
/* The settings the helper started with (main.c loads WEBUI_SETTINGS_PATH before webui_start):
|
|
* /api/settings answers them and /api/settings/set changes them. Call once, before webui_start. */
|
|
void webui_api_settings_init(const webui_settings_t *s);
|
|
|
|
/* A paired PC unregistered the tile (APP_UNREGISTER of WEBUI_TILE_TITLE_ID): the same as Settings ->
|
|
* tile off. Saves tile:false to WEBUI_SETTINGS_PATH (so the next start does not register it again)
|
|
* and asks the tile thread to remove it (webui_tile_request(0): unregister, then the tile folder and
|
|
* the staged /user/app copy are deleted). Returns at once; 0, or -1 when the save failed (the
|
|
* removal is requested either way). */
|
|
int webui_api_tile_off(void);
|
|
|
|
int webui_api_route(const webui_req_t *r, const uint8_t *body, size_t body_len, int fd);
|
|
|
|
/* The streamed routes (webui_server.h webui_stream_fn): POST /api/fs/save-text (a text file of up to
|
|
* 1 MiB: one JSON line, '\n', the text) and POST /api/upload/data?id= (an upload's bytes, after
|
|
* /api/upload/begin). GET /dl/<ticket>/<name> (after /api/download/begin) is served by
|
|
* webui_api_route. None of them reaches a helper method. */
|
|
int webui_api_stream_for(const webui_req_t *r);
|
|
int webui_api_stream(const webui_req_t *r, const uint8_t *pre, size_t pre_len, int fd);
|
|
|
|
#endif
|