Bloomanity's avatar

Read and Process Zip file

What's the best way to upload a zip file with pdfs and have them converted to db entries?

I have 2 entities ResearchCategory and Research

ResearchCategory - id - title - slug - parent_id

Research - id - title - file - category_id

The zip will have folders and files. The folders will be converted to ResearchCategories and the files to Researches in the corresponding category.

0 likes
4 replies
bart's avatar

In my opinion BLOB data (files) should never been stored in a database because this costs a lot of unnecessary MySQL performance. You should store the zip in an upload folder giving a unique file name and reference that name in the database table.

Last but not least, if you really wanna store the data in MySQL (what you shouldn't do in my opinion... ;) ) you could convert it into a base64 string and store it into a mediumblob field.

Bloomanity's avatar

What I want to store is the name of the files and folders, not the actual pdf ... those I'd like to move in an uploads folder.

The thing I'm unable to do (currently) is read the zip contents and convert it to an array; after that parse the array into the corresponding entities and move the files.

Bloomanity's avatar

Ok, at least the zip file content read and unzip process? Anyone?

Please or to participate in this conversation.