PostgreSQL-如何在BYTEA列中插入Base64图像字符串? [英] PostgreSQL - How to insert Base64 images strings into a BYTEA column?

查看:43
本文介绍了PostgreSQL-如何在BYTEA列中插入Base64图像字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下SQL:

CREATE TABLE Documents (
  Id INT NOT NULL,
  UserId INT NOT NULL,
  Label CHARACTER VARYING(220) NOT NULL,
  Image BYTEA NOT NULL,
  PRIMARY Key(Id),
  FOREIGN KEY (UserId) REFERENCES Users(Id)
);

我想知道,我应该如何将Base64映像插入表中.

I want to know, How should I have to insert the Base64 image into the table.

使用 fs 模块.

我正在尝试使用Sequelize的原始查询插入图像,但是我没有找到适当的信息.

I'm attempting to insert the image using raw queries of Sequelize, but I have not found proper information on this.

推荐答案

尝试一下:

insert into table_name (image)
values decode('AcAAFBAO5Az....AQAAAFBCO5gT/AEAABT', 'base64')

以下是有关 decode

https://www.base64decode.net/postgresql-decode

这篇关于PostgreSQL-如何在BYTEA列中插入Base64图像字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆