Welcome, Guest
Username: Password: Remember me

TOPIC: [CLOSED] File upload process

File upload process 16 Sep 2013 07:46 #11097

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
Actually the file upload process in any jcook-generated component is:
  1. User save the item
  2. controller calls the model to save item
  3. Item saved. Controller (postSaveHook) calls again the model to save the files evenually uploaded with the item
  4. The model(_upload) does the tasks needed on the file and THEN eventually SAVE the new filename into the ITEM

if we have 1 file to upload, this process will require 2 SAVE processes (1 to save the item, 1 to save the filename).
It's still acceptable, but if we have for example 6 files to upload and maybe many users at the same time, this process is not convenient at all.
I would move the upload process BEFORE the Item save process, so I can update the filenames and save any modifications in one call.
The administrator has disabled public write access.

File upload process 23 Sep 2013 22:19 #11166

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I understand your point of view.

Before, it was as you say. File uploading before saving the item.
My point of view is that the file can now be renamed using the informations of the item. when item is new, saving the item should be done before, because it returns the ID, which is very usefull to save/sort the files.

I think a simple call to update value in DB is not a big deal and users are not uploading files in mass. It should create other I/O repercussions before to have CPU problems. It is not a big deal.

I prefer the way Cook is doing now because the item is the basement of the file. It can exist item without file but NOT the contrary.
I your way, a same file could be uploaded many times before that the item physically validated and accepted in database. It can create unconsistencies such as not-indexed files using precious space on disk.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.073 seconds

Get Started