Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We have something like 1,500 files that need importing. What's the sanest way to do that?
Comment | File | Size | Author |
---|---|---|---|
#20 | filefield_import.tar_.gz | 1.98 KB | filoquin |
Comments
Comment #1
drewish CreditAttribution: drewish commenteduse the batch api and to avoid timeouts. that's not shown
here's a reasonably generic function to create nodes:
this will help you figure out where the widget wants it's files stored (it should probably become a function in filefield.module):
And here's an example of calling it you'll need to validate then save the files then plug them into the node (I'm doing multiple imagefields) this would be the part that would be a single batch api operation:
Comment #2
drewish CreditAttribution: drewish commentedComment #3
dirkson CreditAttribution: dirkson commentedAwesome. That's a ton of info, and should serve me well, whenever I get around to actually pulling all these files in. Very high thanks!
Comment #4
grandcat CreditAttribution: grandcat commentedOh, great, also very high thanks. I can need your code to do quite a good integration of ImageField (based on FileField) in Image FUpload (mass uploading via Flash =)
Comment #5
grandcat CreditAttribution: grandcat commentedI used this code to get the suitable validators for my imagefield, but I find it curious that it isn't tested if this is a real image file, not a fake like a renamed PDF, for example. But this seems to be a bug of imagefield, right?
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #7
mecano CreditAttribution: mecano commentedWhere is this imagefield_widget_upload_validators function gone? I have not been able to locate such function in last imagefield rev (imagefield-6.x-3.0-alpha2)!
Comment #8
anantagati CreditAttribution: anantagati commentedThank you Drewish. With your help (from #1) was easy to make batch with image upload.
Comment #9
trogie CreditAttribution: trogie commentedI have been fighting a few days now to find a way to add imagefield files to existing nodes (thus editing). I try to load the node (node_load) add the file array (after the validators and other checking) and submit and save the node...
In fact I'm trying to move my img_attached images on nodes to imagefields without 'destroying' the original images.
Comment #10
greg.harveyWhat format should
$files
take? No matter what I throw at this, the result is the field's array in the node object is totally empty and no files are imported. I can't get this (or any other) approach to work. This *should* be simple, but for some reason I cannot make filefield data stick to a new node in a script at all. It's driving me crazy. =(Comment #11
drewish CreditAttribution: drewish commentedgreg.harvey $files is an array keyed by the field name with a file (object?) as the value.
Comment #12
greg.harveyThanks drewish! Btw, is there a reference for the Drupal 6.x file object anywhere? I couldn't find one - had to attach a file to a node and vardump the node object to get the structure!
Comment #13
quicksketchgreg.harvey, the $file object is (rather lamely) a direct mapping of the "files" database table.
Comment #14
greg.harveyAh, that's straight-forward enough! Thanks, quicksketch! =)
Comment #15
quicksketchI'm moving this back to closed. I'd highly suggest taking a look at Image FUpload module, which has implemented this method and added a Flash uploading interface for bulk uploads.
Comment #17
davebv CreditAttribution: davebv commentedIs this code importing just one file to one field or are you able to import several files to one node with a filefield with multiple values?
Comment #20
filoquin CreditAttribution: filoquin commentedIm using this module to import in multiples filefield.