Issue with export/import using CLI and file paths not working properly.

14 replies
Last updated: Sep 6, 2021
I’m still (reported this a few months ago) having issues with export/import using the CLI. All imports fail with the same error
Error: Error while fetching asset from "file://./images/<image-name>.<ext>":
File does not exist at the specified endpoint
If I change that path to be absolutely defined from the root of my computer (
/Users/<username>/path/to/sanity/project/export/images/<image-name>.ext
) it works.
Seems strange that I have to go and do that for all assets (not only images, files are affected in the same way). Does this only happen to me?
Aug 30, 2021, 11:27 AM
@sanity/cli version 2.16.0
Aug 30, 2021, 11:28 AM
Have you tried importing the .tar.gz file?
Or are you unzipping, and then importing the .ndjson file?
Aug 30, 2021, 11:31 AM
unzipping, the docs say to import the
data.ndjson
file.
Aug 30, 2021, 11:32 AM
Actually, this page says to import
data.ndjson
https://www.sanity.io/docs/importing-data and this one just says to import
[FILE | FOLDER | URL]
https://www.sanity.io/docs/migrating-data
Aug 30, 2021, 11:34 AM
Sorry this has caused issues for a few months, User. My understanding of export/import is that pulling in the
.ndjson
file directly would be useful if making a batch change to content, for example, but that in most use cases one would want to pull in everything. On the Migrating Data page, there’s a line at the end of the Gotcha—“Make sure though to bring your assets along for the ride if this is the workflow you have chosen”—that needs to be much more prominent.
I’d be curious to know if User’s suggestion to import the whole tarball works for you. I’d like to make these two pages clearer and include a more complete provision of use cases.
Aug 30, 2021, 2:16 PM
Ah User, don’t sweat it! It’s just been months since I last tried so it’s not like I’ve suffered for months 😂
Hmm, that doesn’t really say anything at all that would help
😅 There’s no definition of how I’d bring along the data for the ride. Also, I haven’t even seen anywhere that you can import the tarball directly so not sure what I’ve missed here but I didn’t even know it was possible until today.
I make batch changes every now and then, but with enough time in between for me to forget how
😄 (today was one of those days), like if I change a type for example which would be relatively common I imagine.
Aug 30, 2021, 2:22 PM
Hmm, that doesn’t really say anything at all that would help  There’s no definition of how I’d bring along the data for the ride.
Sorry, prominent was the wrong word. You’re absolutely right that they need to be elaborated on, which I’ll do this week. I’ll ping you once I’m done as I’d like to invite your feedback, if that works for you.
Aug 30, 2021, 2:42 PM
Of course mate! Love to help
Aug 30, 2021, 2:43 PM
How did you go with the
.tar.gz
import? I used to run into this myself until I found out you could import the export bundle itself.
Aug 30, 2021, 4:04 PM
I didn't get a chance to try it, was pretty late over here. I already got the import working by changing all the file paths to start from the root. I've got another project that needs a migration between datasets this week as well so I'll try that then and let you know
Aug 30, 2021, 11:07 PM
Both https://www.sanity.io/docs/migrating-data and https://www.sanity.io/docs/importing-data have been updated—hopefully to clarify what is possible and improve the experience. User or anyone else, I’d welcome any feedback.
Sep 4, 2021, 6:14 PM
Thanks User, I'll check it out tomorrow
Sep 5, 2021, 12:24 AM
Awesome
user A
, that will be very helpful! Looks like it covers everything now. 🙏
Sep 6, 2021, 1:41 AM
Thanks for reviewing those, User. I appreciate that you pointed these out and hope you'll continue to do so. 🙌
Sep 6, 2021, 3:33 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?