libreant
libreant copied to clipboard
Import/Export item with files, too
This depends on #74 ; the idea is to export not only metadata, but also the files attached to it.
This will be a small step towards the achievement of "trusted nodes can share books".
I think that tarball or zipfiles can be a good export format; they are both simple, widely supported (python has standard libraries to read it), and allow a rich and flexible structure.
For example, we could export books like these:
bookexport/v1/id_of_a_book/metadata.json
bookexport/v1/id_of_a_book/files/fileone.pdf
bookexport/v1/id_of_a_book/files/filetwo.epub
bookexport/v1/id_of_another_book/metadata.json
Having a "prefix" (bookexport) can make it immediately understandable what's inside the archive. Having a "version" can make it easier to introduce format changes: if one really needs to change the export format, just increment the version.
Both tarball and zip permit to have a "tree" inside of them. So how to choose? zipfiles are usually more efficient because they're indexed and permit fast random access. Also, they allow to store some files compressed and other uncompressed (see zip.write, which is smart when you have some file that is compressable (json, epub, probably more) and others that are not (pdf, jpg, whatever).
I think that zipfiles are the best solution, but I am really curious about others, totally different, solutions.