Create a file using a staged upload URL
Description
Create a file asset using a staged upload URL after uploading the file using the
[`stagedUploadsCreate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/stagedUploadsCreate) mutation.
This two-step process allows you to first upload large files to a temporary staging location, then create the file record.
The example demonstrates creating an image file from a staged upload, which is ideal for large files or batch uploads.
The response returns the file ID, upload status, alt text, creation timestamp, and image dimensions.
Learn more about [managing media for products](https://shopify.dev/docs/apps/build/online-store/product-media)
and [uploading files](https://help.shopify.com/manual/shopify-admin/productivity-tools/file-uploads).
Query
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
}
userErrors {
field
message
}
}
}
Variables
{
"files": [
{
"alt": "Product showcase image from staged upload",
"contentType": "IMAGE",
"originalSource": "https://snowdevil.myshopify.com/admin/tmp/files/staged-image-upload-123.jpg"
}
]
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation fileCreate($files: [FileCreateInput!]!) { fileCreate(files: $files) { files { id fileStatus alt createdAt ... on MediaImage { image { width height } } } userErrors { field message } } }",
"variables": {
"files": [
{
"alt": "Product showcase image from staged upload",
"contentType": "IMAGE",
"originalSource": "https://snowdevil.myshopify.com/admin/tmp/files/staged-image-upload-123.jpg"
}
]
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"files": [
{
"alt": "Product showcase image from staged upload",
"contentType": "IMAGE",
"originalSource": "https://snowdevil.myshopify.com/admin/tmp/files/staged-image-upload-123.jpg"
}
]
},
},
);
const data = await response.json();
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"files": [{"alt"=>"Product showcase image from staged upload", "contentType"=>"IMAGE", "originalSource"=>"https://snowdevil.myshopify.com/admin/tmp/files/staged-image-upload-123.jpg"}]
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"files": [
{
"alt": "Product showcase image from staged upload",
"contentType": "IMAGE",
"originalSource": "https://snowdevil.myshopify.com/admin/tmp/files/staged-image-upload-123.jpg"
}
]
},
},
});
Response
{
"fileCreate": {
"files": [
{
"id": "gid://shopify/MediaImage/1072273436",
"fileStatus": "READY",
"alt": "Product showcase image from staged upload",
"createdAt": "2025-06-21T03:47:03Z",
"image": {
"width": 372,
"height": 110
}
}
],
"userErrors": []
}
}
Create mixed media files with custom filenames
Description
Create different types of media files including images and documents with custom filenames for better organization.
This example demonstrates how to handle multiple [`contentType`](https://shopify.dev/docs/api/admin-graphql/latest/enums/FileContentType)
values in a single file creation operation with descriptive naming conventions.
The mutation downloads content from external URLs and creates file records simultaneously, each with appropriate metadata and custom filenames that reflect their purpose.
The response returns file IDs, upload status, alt text, and creation timestamps, plus type-specific data like image dimensions and document URLs.
Query
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
... on GenericFile {
url
}
}
userErrors {
field
message
}
}
}
Variables
{
"files": [
{
"alt": "High-resolution product showcase image",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/product-photo.jpg",
"filename": "product-hero-image.jpg"
},
{
"alt": "Technical specifications and dimensions",
"contentType": "FILE",
"originalSource": "https://example.com/specifications.pdf",
"filename": "technical-specifications.pdf"
},
{
"alt": "Product inventory and pricing data",
"contentType": "FILE",
"originalSource": "https://example.com/product-data.xlsx",
"filename": "product-data-sheet.xlsx"
}
]
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation fileCreate($files: [FileCreateInput!]!) { fileCreate(files: $files) { files { id fileStatus alt createdAt ... on MediaImage { image { width height } } ... on GenericFile { url } } userErrors { field message } } }",
"variables": {
"files": [
{
"alt": "High-resolution product showcase image",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/product-photo.jpg",
"filename": "product-hero-image.jpg"
},
{
"alt": "Technical specifications and dimensions",
"contentType": "FILE",
"originalSource": "https://example.com/specifications.pdf",
"filename": "technical-specifications.pdf"
},
{
"alt": "Product inventory and pricing data",
"contentType": "FILE",
"originalSource": "https://example.com/product-data.xlsx",
"filename": "product-data-sheet.xlsx"
}
]
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
... on GenericFile {
url
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"files": [
{
"alt": "High-resolution product showcase image",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/product-photo.jpg",
"filename": "product-hero-image.jpg"
},
{
"alt": "Technical specifications and dimensions",
"contentType": "FILE",
"originalSource": "https://example.com/specifications.pdf",
"filename": "technical-specifications.pdf"
},
{
"alt": "Product inventory and pricing data",
"contentType": "FILE",
"originalSource": "https://example.com/product-data.xlsx",
"filename": "product-data-sheet.xlsx"
}
]
},
},
);
const data = await response.json();
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
... on GenericFile {
url
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"files": [{"alt"=>"High-resolution product showcase image", "contentType"=>"IMAGE", "originalSource"=>"https://burst.shopifycdn.com/photos/product-photo.jpg", "filename"=>"product-hero-image.jpg"}, {"alt"=>"Technical specifications and dimensions", "contentType"=>"FILE", "originalSource"=>"https://example.com/specifications.pdf", "filename"=>"technical-specifications.pdf"}, {"alt"=>"Product inventory and pricing data", "contentType"=>"FILE", "originalSource"=>"https://example.com/product-data.xlsx", "filename"=>"product-data-sheet.xlsx"}]
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
... on GenericFile {
url
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"files": [
{
"alt": "High-resolution product showcase image",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/product-photo.jpg",
"filename": "product-hero-image.jpg"
},
{
"alt": "Technical specifications and dimensions",
"contentType": "FILE",
"originalSource": "https://example.com/specifications.pdf",
"filename": "technical-specifications.pdf"
},
{
"alt": "Product inventory and pricing data",
"contentType": "FILE",
"originalSource": "https://example.com/product-data.xlsx",
"filename": "product-data-sheet.xlsx"
}
]
},
},
});
Response
{
"fileCreate": {
"files": [
{
"id": "gid://shopify/MediaImage/1072273439",
"fileStatus": "READY",
"alt": "High-resolution product showcase image",
"createdAt": "2025-06-21T03:47:11Z",
"image": {
"width": 372,
"height": 110
}
},
{
"id": "gid://shopify/GenericFile/1072273440",
"fileStatus": "READY",
"alt": "Technical specifications and dimensions",
"createdAt": "2025-06-21T03:47:11Z",
"url": "https://cdn.shopify.com/s/files/1/2637/1970/files/specifications.pdf?v=1750477634"
},
{
"id": "gid://shopify/GenericFile/1072273441",
"fileStatus": "READY",
"alt": "Product inventory and pricing data",
"createdAt": "2025-06-21T03:47:12Z",
"url": "https://cdn.shopify.com/s/files/1/2637/1970/files/product-data.xlsx?v=1750477637"
}
],
"userErrors": []
}
}
Create product documentation files from external URLs
Description
Create product documentation files such as user manuals, warranty information, and installation guides.
This example shows how to create PDF and text files from external URLs that customers can download for product support.
The response returns file IDs, upload status, alt text, creation timestamps, and download URLs for each created document.
Learn more about [managing media for products](https://shopify.dev/docs/apps/build/online-store/product-media)
and [uploading files](https://help.shopify.com/manual/shopify-admin/productivity-tools/file-uploads).
Query
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on GenericFile {
url
}
}
userErrors {
field
message
}
}
}
Variables
{
"files": [
{
"alt": "Complete user manual and setup instructions",
"contentType": "FILE",
"originalSource": "https://example.com/user-manual.pdf",
"filename": "product-user-manual.pdf"
},
{
"alt": "Warranty terms and conditions document",
"contentType": "FILE",
"originalSource": "https://example.com/warranty-info.txt",
"filename": "warranty-information.txt"
}
]
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation fileCreate($files: [FileCreateInput!]!) { fileCreate(files: $files) { files { id fileStatus alt createdAt ... on GenericFile { url } } userErrors { field message } } }",
"variables": {
"files": [
{
"alt": "Complete user manual and setup instructions",
"contentType": "FILE",
"originalSource": "https://example.com/user-manual.pdf",
"filename": "product-user-manual.pdf"
},
{
"alt": "Warranty terms and conditions document",
"contentType": "FILE",
"originalSource": "https://example.com/warranty-info.txt",
"filename": "warranty-information.txt"
}
]
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on GenericFile {
url
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"files": [
{
"alt": "Complete user manual and setup instructions",
"contentType": "FILE",
"originalSource": "https://example.com/user-manual.pdf",
"filename": "product-user-manual.pdf"
},
{
"alt": "Warranty terms and conditions document",
"contentType": "FILE",
"originalSource": "https://example.com/warranty-info.txt",
"filename": "warranty-information.txt"
}
]
},
},
);
const data = await response.json();
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on GenericFile {
url
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"files": [{"alt"=>"Complete user manual and setup instructions", "contentType"=>"FILE", "originalSource"=>"https://example.com/user-manual.pdf", "filename"=>"product-user-manual.pdf"}, {"alt"=>"Warranty terms and conditions document", "contentType"=>"FILE", "originalSource"=>"https://example.com/warranty-info.txt", "filename"=>"warranty-information.txt"}]
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on GenericFile {
url
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"files": [
{
"alt": "Complete user manual and setup instructions",
"contentType": "FILE",
"originalSource": "https://example.com/user-manual.pdf",
"filename": "product-user-manual.pdf"
},
{
"alt": "Warranty terms and conditions document",
"contentType": "FILE",
"originalSource": "https://example.com/warranty-info.txt",
"filename": "warranty-information.txt"
}
]
},
},
});
Response
{
"fileCreate": {
"files": [
{
"id": "gid://shopify/GenericFile/1072273437",
"fileStatus": "READY",
"alt": "Complete user manual and setup instructions",
"createdAt": "2025-06-21T03:47:06Z",
"url": "https://cdn.shopify.com/s/files/1/2637/1970/files/user-manual.pdf?v=1750477627"
},
{
"id": "gid://shopify/GenericFile/1072273438",
"fileStatus": "READY",
"alt": "Warranty terms and conditions document",
"createdAt": "2025-06-21T03:47:06Z",
"url": "https://cdn.shopify.com/s/files/1/2637/1970/files/warranty-info.txt?v=1750477629"
}
],
"userErrors": []
}
}
Create product image files from external URLs
Description
Create multiple product image files from external URLs to build a visual gallery for a product.
This example demonstrates creating two product image files with descriptive alt text for accessibility.
The mutation downloads the images from external URLs and creates file records, returning their file IDs, upload status, alt text,
creation timestamps, and image dimensions (width and height).
Learn more about [managing media for products](https://shopify.dev/docs/apps/build/online-store/product-media)
and [uploading files](https://help.shopify.com/manual/shopify-admin/productivity-tools/file-uploads).
Query
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
}
userErrors {
field
message
}
}
}
Variables
{
"files": [
{
"alt": "Laptop computer on modern desk setup",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/laptop-on-desk.jpg"
},
{
"alt": "Close-up view of laptop keyboard and screen",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/laptop-closeup.jpg"
}
]
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation fileCreate($files: [FileCreateInput!]!) { fileCreate(files: $files) { files { id fileStatus alt createdAt ... on MediaImage { image { width height } } } userErrors { field message } } }",
"variables": {
"files": [
{
"alt": "Laptop computer on modern desk setup",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/laptop-on-desk.jpg"
},
{
"alt": "Close-up view of laptop keyboard and screen",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/laptop-closeup.jpg"
}
]
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"files": [
{
"alt": "Laptop computer on modern desk setup",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/laptop-on-desk.jpg"
},
{
"alt": "Close-up view of laptop keyboard and screen",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/laptop-closeup.jpg"
}
]
},
},
);
const data = await response.json();
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"files": [{"alt"=>"Laptop computer on modern desk setup", "contentType"=>"IMAGE", "originalSource"=>"https://burst.shopifycdn.com/photos/laptop-on-desk.jpg"}, {"alt"=>"Close-up view of laptop keyboard and screen", "contentType"=>"IMAGE", "originalSource"=>"https://burst.shopifycdn.com/photos/laptop-closeup.jpg"}]
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
... on MediaImage {
image {
width
height
}
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"files": [
{
"alt": "Laptop computer on modern desk setup",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/laptop-on-desk.jpg"
},
{
"alt": "Close-up view of laptop keyboard and screen",
"contentType": "IMAGE",
"originalSource": "https://burst.shopifycdn.com/photos/laptop-closeup.jpg"
}
]
},
},
});
Response
{
"fileCreate": {
"files": [
{
"id": "gid://shopify/MediaImage/1072273434",
"fileStatus": "READY",
"alt": "Laptop computer on modern desk setup",
"createdAt": "2025-06-21T03:46:57Z",
"image": {
"width": 372,
"height": 110
}
},
{
"id": "gid://shopify/MediaImage/1072273435",
"fileStatus": "READY",
"alt": "Close-up view of laptop keyboard and screen",
"createdAt": "2025-06-21T03:46:57Z",
"image": {
"width": 372,
"height": 110
}
}
],
"userErrors": []
}
}
Handle file creation errors and validation
Description
This example shows how the mutation responds to common errors like invalid URLs and unsupported file extensions.
The response includes detailed user errors with specific field paths and error codes to help identify and resolve issues.
Query
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
}
userErrors {
field
message
code
}
}
}
Variables
{
"files": [
{
"alt": "Invalid URL example",
"contentType": "IMAGE",
"originalSource": "not-a-valid-url"
},
{
"alt": "Unsupported file type example",
"contentType": "IMAGE",
"originalSource": "https://example.com/document.html"
},
{
"contentType": "IMAGE",
"originalSource": "https://example.com/image.jpg",
"alt": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
]
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation fileCreate($files: [FileCreateInput!]!) { fileCreate(files: $files) { files { id fileStatus alt createdAt } userErrors { field message code } } }",
"variables": {
"files": [
{
"alt": "Invalid URL example",
"contentType": "IMAGE",
"originalSource": "not-a-valid-url"
},
{
"alt": "Unsupported file type example",
"contentType": "IMAGE",
"originalSource": "https://example.com/document.html"
},
{
"contentType": "IMAGE",
"originalSource": "https://example.com/image.jpg",
"alt": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
]
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
}
userErrors {
field
message
code
}
}
}`,
{
variables: {
"files": [
{
"alt": "Invalid URL example",
"contentType": "IMAGE",
"originalSource": "not-a-valid-url"
},
{
"alt": "Unsupported file type example",
"contentType": "IMAGE",
"originalSource": "https://example.com/document.html"
},
{
"contentType": "IMAGE",
"originalSource": "https://example.com/image.jpg",
"alt": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
]
},
},
);
const data = await response.json();
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
}
userErrors {
field
message
code
}
}
}
QUERY
variables = {
"files": [{"alt"=>"Invalid URL example", "contentType"=>"IMAGE", "originalSource"=>"not-a-valid-url"}, {"alt"=>"Unsupported file type example", "contentType"=>"IMAGE", "originalSource"=>"https://example.com/document.html"}, {"contentType"=>"IMAGE", "originalSource"=>"https://example.com/image.jpg", "alt"=>"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}]
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
id
fileStatus
alt
createdAt
}
userErrors {
field
message
code
}
}
}`,
"variables": {
"files": [
{
"alt": "Invalid URL example",
"contentType": "IMAGE",
"originalSource": "not-a-valid-url"
},
{
"alt": "Unsupported file type example",
"contentType": "IMAGE",
"originalSource": "https://example.com/document.html"
},
{
"contentType": "IMAGE",
"originalSource": "https://example.com/image.jpg",
"alt": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
]
},
},
});
Response
{
"fileCreate": {
"files": [],
"userErrors": [
{
"field": [
"files",
"0",
"originalSource"
],
"message": "Image URL is invalid",
"code": "INVALID"
},
{
"field": [
"files",
"1",
"originalSource"
],
"message": "The file type is not supported.",
"code": "UNACCEPTABLE_ASSET"
},
{
"field": [
"files",
"2",
"alt"
],
"message": "The alt value exceeds the maximum limit of 512 characters.",
"code": "ALT_VALUE_LIMIT_EXCEEDED"
}
]
}
}