跳转到主要内容

omni_aws

Omnigres AWS S3 API封装

omnigres · Omnigres AWS S3 API封装

概览

ID扩展软件包版本类别许可证编程语言
2942omni_awsomnigres0.1.2FEATApache-2.0C
属性可执行文件动态库需要预加载需要建扩展可迁移可信
----dt-否否否是否是

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY0.1.219 18 17 16 15omnigresomni_httpc, pgcrypto, omni_xml, omni_web
RPMPIGSTY2026021219 18 17 16 15omnigres_$vpostgresql$v-contrib, postgresql$v-plpython3, python3-pip
DEBPIGSTY2026021219 18 17 16 15postgresql-$v-omnigrespostgresql-plpython3-$v, python3-pip
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el8.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el9.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el9.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el10.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el10.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d12.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d12.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d13.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d13.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u22.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u22.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u24.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u24.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u26.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u26.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212

源码

pig build pkg omnigres;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install omnigres;		# install by package name
pig install omni_aws;		# install by extension name

pig install omni_aws -v 18;   # install for PG 18
pig install omni_aws -v 17;   # install for PG 17
pig install omni_aws -v 16;   # install for PG 16
pig install omni_aws -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION omni_aws CASCADE; -- requires omni_httpc, pgcrypto, omni_xml, omni_web

用法

omni_aws: Amazon Web Services API(S3)

omni_aws 扩展为 PostgreSQL 提供 S3 兼容的 API 函数。

S3 API 函数

s3_create_bucket(bucket, region) – 创建 S3 存储桶。

s3_list_objects_v2(bucket, path, continuation_token, delimiter, encoding_type, fetch_owner, max_keys, start_after, region) – 列出存储桶中的对象,支持分页。

s3_put_object(bucket, path, payload, content_type, region) – 上传对象。默认内容类型为 application/octet-stream。

执行

单个请求:

SELECT * FROM omni_aws.aws_execute(
    access_key_id => 'AKID',
    secret_access_key => 'SECRET',
    request => omni_aws.s3_put_object('my-bucket', '/path/to/file', 'content'::bytea)
);

批量请求: 将 requests 作为数组传入以实现高效批量操作。返回带 error 列的表。

预签名 URL

SELECT omni_aws.s3_presigned_url(
    bucket => 'my-bucket',
    path => '/my-file',
    access_key_id => 'AKID',
    secret_access_key => 'SECRET',
    expires => 604800,  -- 7 天(默认)
    region => 'us-east-1'
);

自定义端点

  • DigitalOcean Spaces: digitalocean_s3_endpoint()
  • 通用端点: s3_endpoint(url),支持 ${region} 和 ${bucket} 变量,适用于 MinIO 等兼容服务

表格阅读器