Copying / migrating documents generically

I’ve build an inadequate solution to migrate various documents (of varying types) from one key prefix to another (we call them regions). To facilitate this, I’ve been using LegacyDocument.

The problem is that the data is getting corrupted during the transfer of binary data; in this case, it’s string data that’s been appended to, but obviously we want a very generic solution.

Our current solution uses a view to determine all matching keys, retrieve data as LegacyDocument, refactor the key for region desired, and write the document back out. For JSON documents, we merely detect if the data starts with { and ends with } and convert that to a JSON document to maximize correctness. All the others are left as LegacyDocument.

Thanks for any ideas…


One thing you could do is implement your own transcoder/document type that just takes the flags it gets, not checking them and then using them on storage again.

Check out one of the current transcoders/document instances and once written you can register them on openBucket.

Let me know if you need help writing one of those and/or you get stuck :slight_smile: