Asset Management Question

edited August 2015 in Modules
Hi,

I have a module where I can upload an asset. The asset name is also saves in the database table.
Now if the record is updated with a new asset, I want to delete the old one on the file system.

In which hook do I have access to the new filename and the old one from the database so I can check for the difference of the two filenames?

Comments

  • Maybe over-ride base_module_model::on_before_save() and delete your old image there?
  • edited 3:35AM
    Hi,
    my problem is that in the input parameter $values of on_before_save the new value is not available, only the old value. So I do not know if the image has changed at this moment.
  • edited 3:35AM
    on_after_post will have be after a new save so you will have access to the currently saved information and can re-query for the record object by using $this->find_by_key($values['id']) (since $values is just an array).
  • edited 3:35AM
    Hi,
    do you have a method implemented to read the last modified timestamp of an asset on the filesystem? do get the datetime when it was uploaded...
  • edited 3:35AM
    Codeigniter has the get_file_info() function that is found in the file_helper (so you may need to load the file helper)
    http://www.codeigniter.com/user_guide/helpers/file_helper.html#get_file_info
  • edited 3:35AM
    Ok, I know that function. Just thought I have missed a helper function in Fuel :-)
    Then I will use that to write an own helper function to get the filesize. Thanks!
Sign In or Register to comment.