Importing slices containing media items using the import/export feature

Hello, I'm trying to import using the import/export functionality some slices containing media items in the "repeat" part.

In order to have a model, I started to export our data and then I created a test json.

The exported json :

{
  "body": [
    {
      "key": "segments$4803dc25-4cfb-4ebc-aece-2210fe5b7a1e",
      "value": {
        "repeat": [
          {
            "reference": {
              "id": "YCz2CBEAACUALtz4",
              "url": "https://prismic-io.s3.amazonaws.com/yousigncom/b7f32043-3046-4228-a465-21e95c94a849_legal-yellow%402x.png",
              "name": "legal-yellow@2x.png",
              "kind": "image",
              "date": "02/17/21 10:43",
              "size": "592086",
              "width": "682",
              "height": "680",
              "wioUrl": "wio://medias/YCz2CBEAACUALtz4"
            }
          },
          {
            "reference": {
              "id": "YCVGrxEAACgADUzt",
              "url": "https://prismic-io.s3.amazonaws.com/yousigncom/8a549fa2-b143-4927-9b60-4114c0472a95_marker-pink%402x.png",
              "name": "marker-pink@2x.png",
              "kind": "image",
              "date": "10/13/20 08:27",
              "size": "495853",
              "width": "680",
              "height": "680",
              "wioUrl": "wio://medias/YCVGrxEAACgADUzt"
            }
          }
        ],
        "non-repeat": { "segment_label": "Segment 1" }
      }
    },
    {
      "key": "segments$e7199340-a06f-4cc6-904f-02fc87dd6023",
      "value": {
        "repeat": [
          {
            "reference": {
              "id": "YCVGThEAACgADUxY",
              "url": "https://prismic-io.s3.amazonaws.com/yousigncom/03471b1e-6b25-4f29-ba0c-67863cc31970_storage-green%402x.png",
              "name": "storage-green@2x.png",
              "kind": "image",
              "date": "10/13/20 08:27",
              "size": "511501",
              "width": "680",
              "height": "680",
              "wioUrl": "wio://medias/YCVGThEAACgADUxY"
            }
          },
          {
            "reference": {
              "id": "YCz2CBEAACcALtz3",
              "url": "https://prismic-io.s3.amazonaws.com/yousigncom/33ef2984-f979-4974-a8f3-d971a3c64440_swipe-yellow%402x.png",
              "name": "swipe-yellow@2x.png",
              "kind": "image",
              "date": "02/17/21 10:47",
              "size": "545624",
              "width": "682",
              "height": "680",
              "wioUrl": "wio://medias/YCz2CBEAACcALtz3"
            }
          }
        ],
        "non-repeat": { "segment_label": "Segment 2" }
      }
    }
  ],
  "type": "segments-references",
  "tags": [],
  "lang": "fr-fr",
  "grouplang": "YDTFeBAAACIAynmz"
}

The json I created to test the import :

{
  "body": [
    {
      "key": "segments",
      "value": {
        "repeat": [
          {
            "reference": {
              "origin": {
                "url": "zendesk.jpg"
              }
            }
          },
          {
            "reference": {
              "origin": {
                "url": "square.jpg"
              }
            }
          }
        ],
        "non-repeat": { "segment_label": "Segment 1" }
      }
    },
    {
      "key": "segments",
      "value": {
        "repeat": [
          {
            "reference": {
              "origin": {
                "url": "nike.png"
              }
            }
          },
          {
            "reference": {
              "origin": {
                "url": "instacart_360.jpg"
              }
            }
          }
        ],
        "non-repeat": { "segment_label": "Segment 2" }
      }
    }
  ],
  "type": "segments-references",
  "lang": "fr-fr"
}

The import feature tell me that the "id", "size", "width" etc must be defined. But my understanding of the documentation Importing images | Prismic Help Center is that we can used an "origin" object to automatically import media items based on a web or locale link.

I would like to understand why I can't do like in the documentation here and if there is a solution.

Thanks,
Arnaud

Hello Arnaud,

Welcome to the Prismic Forum.

In order to analyze further, can you tell me if the images zendesk.jpg, square.jpg, nike.png, and instacart_360.jpg were presented in the zip you tried to import?

Thanks,

Priyanka

Yes they are in the zip as you can see in this screenshot : Capture d’écran du 2021-02-24 14-33-27.png - Google Drive

And here the screenshot of the error shown by the import/export tool : Capture d’écran de 2021-02-24 14-27-47-cut.png - Google Drive

I’m not sure what the issue might be. I’ll need to take a closer look. Can you send me the following?

  • The url of your Prismic repository
  • The zip file you mentioned above that isn’t working

If you don’t want to share this publicly you can send me a direct message.

Hello Priyanka,

I have an alternate idea because importing a json with a url works but not with the "origin" method.

This works:

    {
      "reference": {
        "url": "some url",
        "preview": null
      }
    },

This does not work:

{
  "reference": {
    "origin": {
      "url": "some url",
    }
  }
},

So can I import all my images using media library and then import a json with urls related to these media ? Like that : https://images.prismic.io/yousigncom/1519904817656.png.

I imagine I can do that:

{
  "reference": {
    "url": "https://images.prismic.io/yousigncom/1519904817656.png",
    "preview": null
  }
},

Thanks,
Arnaud

I'm sorry, this was my fault if using "origin" did'nt work ! reference was a link instead of an image.

Thanks,
Arnaud

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.