Unlock seamless workflows and faster delivery with our latest releases- get the details

Issues with importing data and image assets in Sanity CLI

4 replies
Last updated: Jun 9, 2021
Hi folks, I've exported a dataset (
production
) and am trying to import the resulting
.ndjson
into another dataset (
development
). I'm using the Sanity CLI, v2.10.5. I'm running into some issues with importing.
My documents that are type
route
have strong references to
page
documents, and my
page
documents have strong references to image assets. I was able to import my
route
documents by temporarily changing the references to weak ones (find + replace in my
.ndjson
). Is there a better way to do this?
I'm also stumped on how to import images. When I try to import my unmodified exported data, I get the error:
[image ID] references a different project ID than the specified target (asset is in [production_id], importing to [development_id])
. I've read the docs page that the error message mentions, but the suggested fix doesn't apply because I didn't use
--raw
when exporting. Should I be uploading image files rather than importing image assets?
Jun 8, 2021, 7:36 PM
I realized I had exported in a non-standard way, `curl`ing instead of using the
sanity dataset export
. I've done the latter, and the image error I mentioned above is no longer an issue. However, now some non-existent assets are being referenced. Gonna spend some time trying to work through this.
Jun 8, 2021, 9:02 PM
Note that if you havent manually reset the
development
dataset ( ie deleted it to make sure you import to a clean slate šŸ˜… ) it might still contain misconfigured documents from the initial import šŸ¤” if you dont have anything you care about in the
development
dataset this might be something to attempt.
Another note is that I have had some problems with importing
large datasets myself. How many documents and assets are you importing and what is the cumulative size of the dataset?
Jun 9, 2021, 7:55 AM
Note that if you havent manually reset the
development
dataset ( ie deleted it to make sure you import to a clean slate šŸ˜… ) it might still contain misconfigured documents from the initial import šŸ¤” if you dont have anything you care about in the
development
dataset this might be something to attempt.
Another note is that I have had some problems with importing
large datasets myself. How many documents and assets are you importing and what is the cumulative size of the dataset?
Jun 9, 2021, 7:55 AM
Thanks for the suggestions! I managed to figure it out. The exported
data.ndjson
had
file://./images/[image_id]
but it needed to be
file:///local/path/to/images/[image_id]
.
Jun 9, 2021, 2:39 PM

Sanityā€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?