I am working on a module to unzip the contents of my file field after I have submitted the node. I originally tried to do this in hook_node_insert but this did not work for me because my file field has a custom file path and at the time of hook_node_insert the file is still in the default upload location and it is then moved to the custom file path at some later point.

I also though maybe I could implement my unzipping code hook_file_move (which gets called when the file is moved to the custom file path) but it seems that there is no way to verify that the node type from hook_file_move.

Is there some better hook to implement this unzipping code where I can both verify the type of the node and late enough in the content creation process that the file will have been moved to the location of the custom path.

1 Answer 1


Did you try to make your module's weight higher, to make sure your hooks get executed after all other modules' ? The documentation states that node_insert is called after file_attach_insert so it might be worth a try.

  • I tried setting its weight to 500 but still no dice. I think the problem is that the file gets attached (file_attach_insert) before node_insert gets called but then it gets moved afterwards.
    – Mike2012
    Feb 24, 2012 at 22:05
  • 500 may not be enough, but your problem probably lies elsewhere, in the logic of your operation. A workaround could be to set a flag on the node at save time, make the necessary operations on the first node's view, then unset the flag once it's done. Just sayin'.
    – Countzero
    Feb 25, 2012 at 7:55
  • Over the weekend I discovered that my problem only occurs when using the file field path module, apparently this module is what is causing the move. I don't think changing my weight will matter sadly. I must use this module or some other module that will allow me to use node tokens in my path.
    – Mike2012
    Feb 27, 2012 at 17:23
  • It makes sense, but if you're really out of luck my trick still applies : it has the advantage of working whatever module will do something during or just after the upload. Perhaps File Field Path gives a hook to customize its behaviour ?
    – Countzero
    Feb 27, 2012 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.