Syntax
Common parameters
storage_volume: the name of the storage volume whose credentials, endpoint, and region are used for signing. It must be a non-NULL string literal that names an enabled storage volume of theS3type.builtin_storage_volumeis not allowed. See CREATE STORAGE VOLUME.expiration_time: optional. The validity period of the URL in seconds, from1to3600. TINYINT, SMALLINT, INT, and BIGINT are accepted; other types require an explicit CAST. If this parameter is omitted or NULL, the default value of3600is used.
Signing rules
- You must have the USAGE privilege on the storage volume.
- Signing is a local computation. The functions do not access the object, so they do not check whether the object exists or whether the credentials are allowed to read it.
- The URI to sign must be an absolute object URI in the format
<scheme>://<bucket>/<key>. Supported schemes are defined by the BE configuration items3_compatible_fs_list: by defaults3,s3a,s3n,oss,cos,cosn,obs,ks3, andtos. - An object URI to sign must not contain
?; otherwise, presigning fails. - If the storage volume uses temporary credentials, such as an instance profile or an assumed role, the URL stops working when those credentials expire, which can be earlier than
expiration_time. - Invalid argument values cause the query to fail with an error rather than return NULL.
get_presigned_url
uri accepts a constant, column, or expression of the CHAR or VARCHAR type. Returns a VARCHAR value containing the presigned URL. If uri is NULL or an empty string, returns NULL. If uri is an http:// or https:// URL, presigning fails.
get_presigned_file
file_expr accepts a FILE expression, such as the result of to_file or try_to_file. Returns a FILE value. If file_expr is NULL, returns NULL.
Returns a new FILE with only its uri replaced by the presigned URL. All other fields remain unchanged. If uri is NULL, an empty string, or an HTTP/HTTPS URL, returns the FILE unchanged.
To pass a private image or video to ai_complete or ai_embed, use get_presigned_file. The model service reads the object using the full signed URL. Passing the VARCHAR from get_presigned_url directly to ai_embed embeds the URL text. See Embed a video from object storage.
Examples
The following examples use a storage volume namedmedia_volume.
Example 1: Presign an object with the default validity period
Example 2: Presign an object in OSS
Example 3: Presign a FILE value
uri is the presigned URL, with all other fields unchanged.
Example result: