Skip to main content

mediaUploadUrl Mutation

Description​

Generates a pre-signed URL for uploading a file straight to storage, without it going through the API. With an itemRef, one of the item's downloadable files — a PDF, an image or audio, offered to signed-in customers in the item's assets ZIP — into private storage, for the shops trying item files out and SuperAdmins; the upload must send the same Content-Type. Without one, a file for the media library. Either way the file must then be registered with mediaRegister.

mutation mediaUploadUrl(
$itemRef: ID
$filename: String!
$contentType: String!
) {
mediaUploadUrl(
itemRef: $itemRef
filename: $filename
contentType: $contentType
) {
key
signedUrl
}
}

Variables​

{
"itemRef": "ed5ac1492fe6332cc1c23281",
"filename": "example.jpg",
"contentType": "contentType"
}

Response​

{
"mediaUploadUrl": {
"key": "example",
"signedUrl": "example"
}
}

Arguments​

NameTypeDescription
itemRefIDReference ID of the item the file belongs to. Omit it to upload to the media library.
filenameString!Name of the file to upload.
contentTypeString!MIME type of the file. For an item's file: a PDF, an image (JPEG, PNG, WebP) or audio (MP3, WAV, FLAC, AIFF, M4A, OGG). For the media library, any type.

Returns​

MediaUploadUrlResponse!