Skip to main content

mediaRegister Mutation

Description​

Registers a file uploaded with the URL from mediaUploadUrl. With an itemRef, as one of the item's downloadable files: over 50MB or of another type, it is refused and removed (shops trying item files out, and SuperAdmins). Without one, in the media library: images (excluding SVG) get their size variants, and files over 100MB are refused and removed.

mutation mediaRegister(
$itemRef: ID
$key: String!
$filename: String!
$folder: String
) {
mediaRegister(
itemRef: $itemRef
key: $key
filename: $filename
folder: $folder
) {
_id
id
created {
date
}
modified {
date
}
title
alt
caption
ext
mime
size
width
height
url
key
formatArray {
name
ext
mime
width
height
size
url
key
}
folder
itemRef
}
}

Variables​

{
"itemRef": "897774868506e2f7f636077f",
"key": "key",
"filename": "example.jpg",
"folder": "folder"
}

Response​

{
"mediaRegister": {
"_id": "fc9a9585ac1c635c71578efe",
"id": 5498822176613,
"created": {
"date": 1793138991419
},
"modified": {
"date": 1782952573556
},
"title": "example",
"alt": "example",
"caption": "example",
"ext": "example",
"mime": "example",
"size": 42,
"width": 42,
"height": 42,
"url": "https://example.com",
"key": "example",
"formatArray": [
{
"name": "example",
"ext": "example",
"mime": "example",
"width": 42,
"height": 42,
"size": 42,
"url": "https://example.com",
"key": "example"
}
],
"folder": "example",
"itemRef": "7a804d88aaf5dc3fe1e7b233"
}
}

Arguments​

NameTypeDescription
itemRefIDReference ID of the item the file belongs to. Omit it for the media library.
keyString!Storage key returned by mediaUploadUrl.
filenameString!Name of the file as the customer receives it.
folderStringMedia library folder to file the new media in. Ignored for an item's files.

Returns​

Media!