I have a legacy site with user photos and documents that I would like to import in and attach to entities using File/Image field types. I have everything else working fine, but not sure how to approach this, and Googling didn't provide much or maybe I searched wrong.
Is there a solid recipe for fetching files with URLs and uploading/attaching to entity during a migration?
Comments
Comment #1
mikeryanHave you tried just mapping the URL to your image field? E.g.,
If it doesn't work directly, take a look at beer.inc and wine.inc (mappings of field_migrate_example_image) in migrate_example to see some of the arguments you can pass.
Comment #2
kevinquillen commentedOh, so you can just pass the URL to the Field and Drupal takes care of the rest? That's pretty sweet. I'll try that out.
Comment #3
Sifro commentedhave you been able to migrate your file fields? I'm having the same problem too, and i'm finding it pretty hard.
Comment #4
kevinquillen commentedI did not get to try this yet. I expect to do so on Monday.
Comment #5
Sifro commentedOk let me know if you discover something useful... meanwhile, i'm trying my luck with the node_export module... it has some problems with node attachments, but they are being solved. Now a single node export works fine, but there are still memory problems with bulk exports (but a good workaround may be to write a bash script to bulk export nodes one by one).
Comment #6
Sifro commentedOk, i can definitely say that for simpler node-with-attachments imports, node_export module works perfectly! (use latest dev)
Comment #7
kevinquillen commentedI've found that Node Export was unpredictable and hard to make work for nodes with cck or Fields in 6 or 7. Thus is why I am using Migrate, which has worked great.
Anywho, attempting files now. Will let you know of progress from #1.
Comment #8
kevinquillen commentedJust attempted to import documents and link them to their local file system. Here is the error I got for all 1051 document nodes:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'id' cannot be null: INSERT INTO {file_usage} (fid, module, type, id, count) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 52305 [:db_insert_placeholder_1] => file [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 1 ) (/sandbox/includes/file.inc:664)field_document_upload is a File field, and filename is the old local filename on the server.
Comment #9
kevinquillen commentedIt appears spaces need conversion to %20 to get rid of the first error.
Now I just can't make the filename be the original file name. Here is snippet:
The first two times I tried this, it created two document node entities, and a rollback did not remove them.
Comment #10
mikeryanThe file handling has been completely rewritten for Migrate 2.4 - see http://drupal.org/node/1540106. If you upgrade to the latest -dev, you should find it easier to work out how to migrate your files.
Comment #11
mikeryan