Upload video in a metafield

Topic summary

Issue: Difficulty attaching a video to a Shopify metafield (type: file_reference). After generating a staged upload URL via stagedUploadsCreate and uploading the file (multipart), querying files by name doesn’t return a file ID to set on the metafield.

Current approach:

  • Metafield expects a gid for a Video/File.
  • Steps taken: stagedUploadsCreate → upload to staged target → query files(first: 1, query: name) for ID.
  • Problem: No file ID retrieved.

Key guidance (new update):

  • A missing step is identified: use bulkOperationRunMutation as part of Shopify’s bulk import flow.
  • Reference provided to Shopify docs on Bulk Operations (imports), implying the file must be registered/imported after staging before it can be queried and referenced.

Definitions:

  • Metafield: custom field on Shopify resources.
  • stagedUploadsCreate: gets a pre-signed target to upload bytes.
  • bulkOperationRunMutation: executes a bulk import to register uploaded assets.

Status: No confirmation of resolution. Next action: follow the full bulk import process to register the uploaded video so it can be queried and linked in the metafield.

Summarized with AI on December 18. AI used: gpt-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!!

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)

1 Like