Skip to main content
Version: 🚧 Canary

📐 File Storage schemas

File Storage exports OpenAPI query and operation schemas for generating signed image and generic-file upload URLs.

Inventory

ExportRequest locationContract
contentLengthQueryParameterQueryRequired integer byte length, maximum 10000000.
getSignedImageUploadUrlSchemaQuery / responseImage MIME type and content length; 200 signed URL response.
getSignedFileUploadUrlSchemaQuery / responseSafe MIME type and content length; 200 signed URL response.

Details

contentLengthQueryParameter

Definition
LocationFieldTypeRequiredConstraints
QuerycontentLengthintegerYesMaximum 10000000 bytes (10 MB). No minimum is declared.

Used by route: Indirectly by the routes composed from getSignedImageUploadUrlSchema, and by Organization's createChangeRequestRoute. Used by feature: Indirectly by the features composed from getSignedImageUploadUrlSchema, and by Organization's createChangeRequestFeature through createChangeRequestSchema.

View complete source
export const contentLengthQueryParameter: OpenAPIParameter = {
in: 'query',
name: 'contentLength',
required: true,
schema: {maximum: MAX_CONTENT_LENGTH, type: 'integer'},
};

getSignedImageUploadUrlSchema

Definition
LocationFieldTypeRequiredConstraints
QuerycontentTypestringYesEnum: image/jpeg, image/png, image/webp, image/gif, image/svg+xml, image/avif, image/bmp, image/x-icon, image/tiff, image/heif, image/heic.
QuerycontentLengthintegerYesMaximum 10000000 bytes; spread from contentLengthQueryParameter.
200 responseobjectIdstringYesCloud Storage object name/key.
200 responsesignedUrlstring (URI)YesPre-signed storage URL.

The 200 response object has additionalProperties: false.

Used by route: Profile's avatar-upload route, getLogoUploadUrlRoute, getCertificateUploadUrlRoute, getProductImageUploadUrlRoute, and getChatChannelIconUploadUrlRoute. Used by feature: Profile's avatar-upload feature, getLogoUploadUrlFeature, getCertificateUploadUrlFeature, getProductImageUploadUrlFeature, and getChannelIconUploadUrlFeature.

View complete source
export const getSignedImageUploadUrlSchema = withSchema<OpenAPIOperation>({
parameters: [
{in: 'query', name: 'contentType', required: true, schema: {enum: IMAGE_MIME_TYPES, type: 'string'}},
{...contentLengthQueryParameter},
],
responses: {
'200': {
content: {
'application/json': {
schema: {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
objectId: {description: 'Cloud Storage object name/key.', type: 'string'},
signedUrl: {description: 'Pre-signed URL to access the object', format: 'uri', type: 'string'},
},
required: ['objectId', 'signedUrl'],
type: 'object',
},
},
},
description: 'The signed URL and object ID (i.e. name/key) of the file.',
},
},
});

getSignedFileUploadUrlSchema

Definition
LocationFieldTypeRequiredConstraints
QuerycontentTypestringYesA mime-types value excluding the source denylist below.
QuerycontentLengthintegerYesMaximum 10000000 bytes.
200 responseobjectIdstringYesCloud Storage object name/key.
200 responsesignedUrlstring (URI)YesPre-signed storage URL.

The 200 response object has additionalProperties: false.

The excluded MIME types are: application/x-msdownload, application/x-msdos-program, application/x-bat, application/cmd, application/x-msi, application/x-pif, application/javascript, text/vbscript, application/vbs, application/wsf, application/x-powershell, application/x-sh, text/x-python, text/x-perl, application/zip, application/x-rar-compressed, application/x-7z-compressed, application/x-tar, application/gzip, application/x-ms-shortcut, application/x-iso9660-image, application/octet-stream, application/vnd.android.package-archive, and application/java-archive.

Used by route: getChatMessageAttachmentUploadUrlRoute. Used by feature: getChatMessageAttachmentUrlFeature.

View complete source
export const getSignedFileUploadUrlSchema = withSchema<OpenAPIOperation>({
parameters: [
{
in: 'query',
name: 'contentType',
required: true,
schema: {
enum: [...new Set(Object.values(types).filter(type => !DANGEROUS_MIME_TYPES.includes(type)))],
type: 'string',
},
},
{in: 'query', name: 'contentLength', required: true, schema: {maximum: MAX_CONTENT_LENGTH, type: 'integer'}},
],
responses: {
'200': {
content: {
'application/json': {
schema: {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
objectId: {description: 'Cloud Storage object name/key.', type: 'string'},
signedUrl: {description: 'Pre-signed URL to access the object', format: 'uri', type: 'string'},
},
required: ['objectId', 'signedUrl'],
type: 'object',
},
},
},
description: 'The signed URL and object ID (i.e. name/key) of the file.',
},
},
});