0

I have a static site that we have created content types for and moved most of the content over. There are links leading back to the old static site documents. I am looking for a good way to bring these docs into the drupal fold. I understand i'll need to update the path to the doc, but if we can keep the majority of the structure and just update to /default/files/directory/subdirectory/file.ext that would be great.

How does one most successfully import large amounts of documents?

  • If you mean references in body text and whatnot, the only way I know to do this effectively is with a mysql find and replace on the field data in the database to update old file urls to something new. IMO it is easy to create a 'legacy' directory under sites/default/files and place all old site content there... thats typically how I move old assets quick. – Kevin May 17 '17 at 22:30
  • Thanks Kevin. There be an issue with the files being able to be found later as Drupal entities right? – jasonflaherty May 17 '17 at 22:56
  • In that case you would need to actually import those files as entities instead of do a copy move. – Kevin May 17 '17 at 22:57
  • Ok is there some method to do this? In a module or in some other fashion that I'm unaware of? – jasonflaherty May 17 '17 at 22:59
  • Is there a way I can import them keep the file structure and still make them entities? – jasonflaherty May 17 '17 at 23:00
1

What you could have done is use the Migrate module. It allows you to read from various sources (db, files, csv, etc.) and feed them to Drupal (db, files, csv, etc). It's essentially just a pipeline of read->process->save.

What I would do is create 2 migrations, one for the files and one for the pages. You migrate files first which essentially just tells Drupal they exist by creating records of them in the DB and where they are. During migration, Migrate creates a mapping table which tracks the source id (module-generated, you decide, usually by filename or hash) and destination id (entity id) of the content.

Then you migrate the pages. Migrate allows you to do processing on content before it gets saved to Drupal. Using the data from the mapping done in the file migration earlier (the entity ids), you simply need to look for the urls in the page content, use it to find the id Drupal assigned to it when it was migrated (there are APIs for this), generate a url from that ID, and replace the url in the content.

Migration is easier done than said actually. This section extensively explains how to use Migrate. In addition, check out Migrate Extras and Migrate D2D as additional tools. Also, the Migrate module itself has examples in the source code which you can check out. And... a lot of trial and error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.