Skip to content

Commit 40fe412

Browse files
committed
Document image handling
1 parent 90647a2 commit 40fe412

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Filtering Recommentation](https://jsonapi.org/recommendations/#filtering),
4141
and also accepts pagination paramters following the [JSON:API pagination
4242
spec](https://jsonapi.org/format/#fetching-pagination).
4343

44+
Note also that for POSTing new images to the the `/images` endpoint,
45+
we use plain `multipart/form-data` rather than JSON.
46+
4447
#### Synthetic resources
4548

4649
In addition, the following endpoints appear as RESTful resources, but
@@ -166,7 +169,22 @@ to be working properly, so those need their own [lower-level unit tests](spec/se
166169

167170
### Image file handling
168171

169-
**TO DO**
172+
In order to simplify migration from the old GALC servlet and make it easier to
173+
troubleshoot any imaging issues, uploaded images and their generated thumbnails are
174+
managed as a plain directory (in staging and production, a named NetApp volume
175+
also accessible from vm135 as `/netapp/galc_staging` / `/netapp/galc_production/`),
176+
rather than via ActiveStorage or similar.
177+
178+
The [`Image`](app/models/image.rb) class is a plain ActiveRecord model with a corresponding
179+
database table, but also includes code to manage its associated files — reading a Rails
180+
[`UploadedFile`](https://api.rubyonrails.org/v7.0/classes/ActionDispatch/Http/UploadedFile.html)
181+
object from a form POST, writing the file to the appropriate location on disk,
182+
creating and writing a thumbnail, etc.; as well as deleting both thumbnail and full-size
183+
file when the ActiveRecord model object is destroyed.
184+
185+
Besides API endpoints, the [`ImagesController`](app/controllers/images_controller.rb)
186+
is also responsible for streaming the images themselves to the browser — not ideal
187+
for a high-volume application, but good enough for now.
170188

171189
## Build, packaging, and deployment
172190

0 commit comments

Comments
 (0)