Build a management command that imports a list of images and build elements
The new command import_image_list
should take a few parameters:
-
--image-list
is a path towards a list of relative image paths (relative to a IIIF path) -
--iiif-server
is the IIIF server base image url -
--iiif-prefix
is the optional IIIF path -
--corpus
is the required ID of a corpus -
--folder-type
is the slug of a type (default tofolder
) -
--page-type
is the slug of a type (default topage
)
Workflow is :
- check corpus & types exist
- check IIIF server exists
- read each line of the image list file:
- get or create an image on the image server (image path is :
urljoin(iiif-prefix, image path from line)
- get or create the folder hierarchy to match the image path
- get or create a page element for the image
- get or create an image on the image server (image path is :
To summarize, if the file contains:
path/to/imageA.jpg
path/to/imageB.jpg
We should end up with 2 images, in a folder to
, itself in a top folder path
.
Note: it's certainly a lot more performant to first read the whole page file, and build the whole folder hierarchy.
Edited by Bastien Abadie