Skip to main content
Experimental feature Advice on use of experimental features Generate presigned HTTP GET URLs for objects in object storage, allowing clients such as model services to download objects during the validity period without providing an access key (AK) or secret key (SK). Currently, only S3-compatible object storage, such as OSS, is supported.

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 the S3 type. builtin_storage_volume is not allowed. See CREATE STORAGE VOLUME.
  • expiration_time: optional. The validity period of the URL in seconds, from 1 to 3600. TINYINT, SMALLINT, INT, and BIGINT are accepted; other types require an explicit CAST. If this parameter is omitted or NULL, the default value of 3600 is 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 item s3_compatible_fs_list: by default s3, s3a, s3n, oss, cos, cosn, obs, ks3, and tos.
  • 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 named media_volume.

Example 1: Presign an object with the default validity period

The result is similar to the following. The credential, date, and signature differ in your environment.

Example 2: Presign an object in OSS

Example 3: Presign a FILE value

Returns a new FILE whose uri is the presigned URL, with all other fields unchanged. Example result: