Uploads carry the name the file came with (#83)
An upload sends its file name next to the raw bytes, and the server keeps it in a sidecar next to the content-addressed file. Both pickers caption every tile and row with it, and an asset made there is named after the file instead of "Texture" / "Font". Last upload of the same content wins. The API's own set_error_handler ignores error_reporting(), so @-silenced warnings still throw: a missing sidecar took the whole listing down with a 500. Existence is checked instead of suppressed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
86b5363a01
commit
99c5d2ad78
21 files changed
+347
-61
No files matched your search
+12
-8
@@ -13,19 +13,23 @@ declare(strict_types=1);
|
||||
* PUT ?r=projects/{id} {revision, project} → {revision,updatedAt} | 409 {error,revision}
|
||||
* DELETE ?r=projects/{id} → 204
|
||||
*
|
||||
* GET ?r=textures → [{file,width,height,bytes,updatedAt}]
|
||||
* POST ?r=textures raw image bytes → {file,width,height,bytes}
|
||||
* DELETE ?r=textures/{file} → 204
|
||||
* GET ?r=textures → [{file,name,width,height,bytes,updatedAt}]
|
||||
* POST ?r=textures&name=x.png raw image bytes → {file,name,width,height,bytes}
|
||||
* DELETE ?r=textures/{file} → 204
|
||||
*
|
||||
* GET ?r=fonts → [{file,bytes,updatedAt}]
|
||||
* POST ?r=fonts raw font bytes → {file,bytes}
|
||||
* DELETE ?r=fonts/{file} → 204
|
||||
* GET ?r=fonts → [{file,name,bytes,updatedAt}]
|
||||
* POST ?r=fonts&name=x.ttf raw font bytes → {file,name,bytes}
|
||||
* DELETE ?r=fonts/{file} → 204
|
||||
*
|
||||
* `name` is the file's original name, kept beside it as `{file}.json` (see OriginalName) and
|
||||
* empty when none is known. It is a caption, never a path: the stored file is always `{hash}.{ext}`.
|
||||
*
|
||||
* Stored images and fonts are served straight from `data/textures/` and `data/fonts/` as
|
||||
* static files; the API only writes them.
|
||||
*/
|
||||
|
||||
require __DIR__ . '/lib/FontStore.php';
|
||||
require __DIR__ . '/lib/OriginalName.php';
|
||||
require __DIR__ . '/lib/Response.php';
|
||||
require __DIR__ . '/lib/Store.php';
|
||||
require __DIR__ . '/lib/TextureStore.php';
|
||||
@@ -116,7 +120,7 @@ function routeTextures(array $parts, string $method): never
|
||||
Response::error('Image must be at most ' . (MAX_TEXTURE_BYTES / 1024 / 1024) . ' MB', 413);
|
||||
}
|
||||
try {
|
||||
Response::json($store->store($bytes), 201);
|
||||
Response::json($store->store($bytes, (string) ($_GET['name'] ?? '')), 201);
|
||||
} catch (InvalidImageException $e) {
|
||||
Response::error($e->getMessage(), 422);
|
||||
}
|
||||
@@ -149,7 +153,7 @@ function routeFonts(array $parts, string $method): never
|
||||
Response::error('Font must be at most ' . (MAX_FONT_BYTES / 1024 / 1024) . ' MB', 413);
|
||||
}
|
||||
try {
|
||||
Response::json($store->store($bytes), 201);
|
||||
Response::json($store->store($bytes, (string) ($_GET['name'] ?? '')), 201);
|
||||
} catch (InvalidFontException $e) {
|
||||
Response::error($e->getMessage(), 422);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user