Migration: Combine Profile2 and file migration I need to migrate profiles from an external database (not drupal) to Drupal 7. The target system uses Profile2 profiles. I already wrote the migration of all the "primitive" fields with the help of this cookbook, but I'm stuck with the profile images. They are only accessible via url (blah.org/blah/[user_id].jpg, so the migration needs to download them, and store them into a Profile2 profile field with type image. I know there is MigrateDestinationFile, but I dont see how to make the file&lt;->image&lt;->Profile2_field connection. 

Has anyone done that before?
This is not a complete working example but is still more an answer than a comment.

I'm assuming you're familiar with migration code in general.

I also assume you are using Migrate extras, which provides profile 2 support and has an example of a profile2 migration.

Because files are a separate entity from profiles you have to first have a file migration, which migrates the files into Drupal.
In that linked example the first part of code is the file import and the second part is the node import that then uses those files in a file field.
In your case the second part will be very similar but will be in your profile2 migration.

I haven't actually done an import that pulls in images from the web like this so this is an assumption.
I would say set your source directory for your file import to the directory that you intend to download the remote files into.
You can specify your directory like this and make it anywhere on your server: 'source_dir' =&gt; '/var/www/my-downloaded-files',

Then after that you import your profile2 profiles.

Unfortunately I have only done file migrations from Drupal to Drupal so I'm not sure off the top of my head what you specify for the source field when you add your field mapping (I will have a look into it when I get some free time but I'm not sure when that will be).

As far as the actual pulling in of the files goes a possible, relatively straight forward way to get your files from the external source might be to implement one of the migration methods like prepareRow() (see Commonly implemented Migration methods) and have it download the file (you could use drupal_http_request() or cURL or similar) for use in your file migration.

Be sure to handle the case of rollbacks and either remove the local files or before downloading, check if you already have the file then only download if you don't.