My source site's MySQL database stores images as BLOBs, and each press release that I want to migrate can have multiple image BLOBs associated with it. I've managed to successfully implement a migration class that imports the images by themselves (PRAssetMigration in http://pastebin.com/H2j5xeBk), but I'd like to import them as file fields attached to their associated press release nodes.

I've tried to do the multi-value file field method outlined in http://drupal.org/node/1005090, as you can see here: http://pastebin.com/H2j5xeBk in the PRMigation class. But when I run the migration I get dozens of the same error:
You must specify a filename in the 'source_path' argument for file_blog migrations.
('file_blog' appears to be a typo in the error message; should be 'file_blob')

I realize that this is an error related to the MigrateFileFieldHandler arguments... but I have no idea how to tell it what the source_path value should be, since I don't know until prepareRow() is called, and there could be more than one asset filename to deal with.

As an alternative solution to my problem, could I combine my working PRAssetMigration class with some way to associate imported standalone files with imported press releases? I imagine that's probably possible, but I have no idea how to do it for (potentially) multiple files per press release.

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

The source_path argument should be the parent directory where the files generated from the blobs will be saved. If you set that argument to the Drupal default files directory, or some appropriate subdirectory of it, how does that work for you?

coredumperror’s picture

I actually solved my problem by using multiple Field Collections with single-image fields in each one. This was necessary because I also needed to include additional text fields related to the images (caption and photo credit), which the image field alone does not support. Fortunately, the patch for Field Collection which adds support for Migrate works wonderfully, and I've got my image migrations working fine now.

However, if I were to try your suggestion, how would Migrate associate each filename to each blob? Is the 'path' (or 'url') value in the JSON data the same thing as filename? How would the blobs themselves be associated with the rest of the data?

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Postponed
Issue tags: +Migrate 2.4

This will be dealt with in Migrate 2.4, as part of #1240928: META: Refactoring of file destination/field handlers.

mikeryan’s picture

Status: Postponed » Active
mikeryan’s picture

Status: Active » Closed (duplicate)

This is being dealt with in #1240928: META: Refactoring of file destination/field handlers, multi-value file fields will work regardless of whether they're from blobs or URIs.