I am trying to create a Shopify product with an image, video and 3D media.
(mediaContentType “IMAGE”, “EXTERNAL VIDEO” and “MODEL_3D”)
I can create a product with images and video, but the Shopify sample watch 3D (.glb) file produces 'MEDIA Upload failed. 3D Model: Model Failed Validation
Any thoughts or guidance on how to use graphql to upload and attach 3D media files would be most appreciated:
Step 1: Upload 3D Media file
I first use stagedUploadsCreate to get a URL for the watch.glb media file:
mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {
stagedUploadsCreate(input: $input) {
stagedTargets {
url
resourceUrl
parameters {
name
value
}
}
}
}
{
“input”: [
{
“filename”: “https//cdn.shopify.com/3d/models/o/e38516a2d6824caa/watch.glb”,
“mimeType”: “model/gltf-binary”,
“resource”: “MODEL_3D”,
“fileSize”: “3846680”
}
]
}
result:
{
“data”: {
“stagedUploadsCreate”: {
“stagedTargets”: [
{
“url”: “https//storage.googleapis.com/threed-models-production/models/9465bf851f3009b8/https_cdn_shopify_com_3d_models_db67eef5a10e0fab_watch.glb?external_model3d_id=bW9kZWwzZC0xMDg4ODY2”,
“resourceUrl”: “https//storage.googleapis.com/threed-models-production/models/9465bf851f3009b8/https_cdn_shopify_com_3d_models_db67eef5a10e0fab_watch.glb?external_model3d_id=bW9kZWwzZC0xMDg4ODY2”,
…
Step 2 : Create product with media
I then use the url above as OriginalSource for the shopify sample watch:
mutation CreateProductWithNewMedia($input: ProductInput!, $media: [CreateMediaInput!]) {
productCreate(input: $input, media: $media) {
product {
id
title
media(first: 10) {
nodes {
alt
mediaContentType
}
}
}
userErrors {
field
message
}
}
}
{
“input”: {
“title”: "11-16 Helmet, Video, and Shopify 3d Watch "
},
“media”: [
{
“originalSource”: “https//cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png”,
“alt”: “Gray helmet for bikers”,
“mediaContentType”: “IMAGE”
},
{
“originalSource”: “https//www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz”,
“alt”: “Testing helmet resistance against impacts”,
“mediaContentType”: “EXTERNAL_VIDEO”
},
{
“originalSource”:“https//storage.googleapis.com/threed-models-production/models/e0c9b8dd3f52a8fb/https_cdn_shopify_com_3d_models_db67eef5a10e0fab_watch.glb?external_model3d_id=bW9kZWwzZC0xMDg4ODY5”,
“alt”:“3D Desk Google Source”,
“mediaContentType”:“MODEL_3D”
}
]
}
… and get
{
“data”: {
“productCreate”: {
“product”: {
“id”: “gid//shopify/Product/8144445538501”,
“title”: “11-16 Helmet, Video, and Shopify 3d Watch”,
“media”: {
“nodes”: [
{
“alt”: “Gray helmet for bikers”,
“mediaContentType”: “IMAGE”
},
{
“alt”: “Testing helmet resistance against impacts”,
“mediaContentType”: “EXTERNAL_VIDEO”
},
{
“alt”: “3D Desk Google Source”,
“mediaContentType”: “MODEL_3D”
}
]
}
},
“userErrors”:
}
},
“extensions”: {
“cost”: {
“requestedQueryCost”: 16,
“actualQueryCost”: 14,
“throttleStatus”: {
“maximumAvailable”: 2000,
“currentlyAvailable”: 1986,
“restoreRate”: 100
}
}
}
}
However, the product is created with the image and video media, but the MODEL_3D Shopify watch.glb media is not attached it fails with:
'MEDIA Upload failed. 3D Model: Model Failed Validation