Research-IT-Swiss-TPH / pdf-form-filling-api

API to read, fill and flatten PDF forms.
https://143.198.242.211.sslip.io/
0 stars 2 forks source link

Implement sustainable file handling #25

Closed tertek closed 6 months ago

tertek commented 7 months ago

For writing, deleting, updating and reading documents, a sustainable file handling approach is required. The requirements are:

tertek commented 7 months ago

Slim Framework provides an interface with some methods to handle files that could be useful:

The file uploads in $_FILES are available from the Request object’s getUploadedFiles() method. This returns an array keyed by the name of the input element.

Each object in the $files array is an instance of Psr\Http\Message\UploadedFileInterface

For more information: https://www.slimframework.com/docs/v4/objects/request.html#uploaded-files

tertek commented 7 months ago

Additional information on file uploading and handling:

Slim eBook Vol. 2: Chapter "File Uploads", p. 38 - 49 (file upload basics)

Slim eBook Vol. 2: Chapter "Flysystem v3", p.49 - 83 (file storage library)

Slim eBook Vol. 2: Chapter "ZIP files", p.208 - 217 (ZIP File Creation and Download)

Slim eBook Vol. 3 Chapter "Amazon S3", p. 9 - 21 (Simple Storage Service) ; this is only relevant for later, but for now it is good to know how to build the abstraction layer

edenst-TPH commented 6 months ago

secure mime type detection tool for uploads: composer require league/mime-type-detection, see https://ebook.odan-consulting.com/slim4-vol2/articles/file-uploads#usage

tertek commented 6 months ago

secure mime type detection tool for uploads: composer require league/mime-type-detection, see https://ebook.odan-consulting.com/slim4-vol2/articles/file-uploads#usage

https://github.com/thephpleague/mime-type-detection

tertek commented 6 months ago

@edenst-TPH We can build the filesystem service around the Flysystem Adapter: SlimBook vol 2, chapter Flysystem 3 and also

https://flysystem.thephpleague.com/docs/adapter/local/

For now we would only need local

tertek commented 6 months ago

@edenst-TPH I have added FileSystem library and configured. https://github.com/Research-IT-Swiss-TPH/pdf-form-filling-api/tree/FileSystem

It does not work 100% yet. As soon as I have it fixed, it will be merged into DEV.

tertek commented 6 months ago

@edenst-TPH Please check the PR, which is ready to merge: https://github.com/Research-IT-Swiss-TPH/pdf-form-filling-api/pull/37

I will merge tomorrow so that we can continue with the next steps. But it is good for you to know what has been added in the PR.

tertek commented 6 months ago

Merged into dev.