Programmatically attaching files which don't (yet) exist
| Project: | FileField |
| Version: | 6.x-3.2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
I'm working on a module which imports listings from a remote database into local nodes. The listings may include an arbitrary number of images, which are only available by separate remote calls. As the module may import several thousand listings at once, and each listing may have from zero to a couple dozen images, and it's not guaranteed that any particular node's images are going to ever be viewed even once before the node is purged anyway, I've added a menu handler to my module which fires if an image is requested which isn't stored locally yet, and only then tries to fetch it from the server and store it locally for later use.
The trick is that I'd like these images to be attached to the node through an ImageField/FileField so that they can easily be used with ImageCache, Thickbox, etc, and so far I haven't been successful in programmatically attaching these images to nodes - I'm not sure yet, but I suspect it's because the images don't exist. Is there a practical way to go about this? I'm still poking around and trying to find a way myself, but I suspect any method I find is going to be rather hackish and maybe not the best way to solve this problem, so I'd appreciate any insight others may have. Thanks.
