Upload video in a metafield

Upload video in a metafield

LucaRaveri
Shopify Partner
20 3 5

Hello guys,

I'm tryng to upload a video to a metafield.
Here's the metafield specifications:

"metafield": { "id": "gid://shopify/Metafield/30669385302191", "namespace": "custom", "key": "video_pdp", "value": "gid://shopify/Video/31521214628015", "type": "file_reference" }

Here there is the video because i selected one randomly from the shopify backoffice.

What I'm tryng to do now is to generate a staged url with the mutation stagedUploadsCreate:

 

mutation stagedUploadsCreate(\$input: [StagedUploadInput!]!) {
stagedUploadsCreate(input: \$input) {
stagedTargets {
url
resourceUrl
parameters {
name
value
}
}
}
}

 

Than i upload the file to the staged URL with the multipart request.

Finally, I try to get the file id searching the files with the name of my video:

query getFiles(\$query: String!) {
files(first: 1, query: \$query) {
edges {
node {
id
createdAt
fileStatus
}
}
}
}

 

where query === name.

This doesnt'work and I can't retrive the file ID i need in order to upload the video on the metafield.

Any help will be really appreciated, thank you!!

If this was helpful, please Like it ⬆️
If this solved your problem, please Mark it as solution
Reply 1 (1)

Kyle_liu
Shopify Partner
184 27 31

Hi @LucaRaveri 

 

You should be missing a step: https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/bulkoperationrunmutation 

 

The full process is as follows:

Bulk import data with the GraphQL Admin API (shopify.dev)

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me on ([email protected])