이 대답에 따라 .jpg 파일을 테이블 내부의 BLOB 유형 열에 저장하려고했습니다. 이것이 내가 지금까지 가지고있는 것입니다.
테스트 테이블을 만들었습니다.
CREATE TABLE test_lob(
ID NUMBER
, C CLOB
, B BLOB
);
그런 다음이 코드를 작성했습니다.
async function getFile() {
var str = fs.readFileSync('/path/to/image', 'utf8');
await insertBlob(str);
}
...
async function insertBlob(str) {
var connection;
try {
connection = await oracledb.getConnection({
user: process.env.USER,
password: process.env.PASS,
connectString: process.env.SERVER_CONNECT_STRING
});
const result = await connection.execute(
`
INSERT INTO test_lob(id, b) VALUES(1, :b)
`,
{ b: str },
{ autoCommit: true }
);
console.log(result);
} catch(err) {
console.error(err);
} finally {
if(connection) {
try {
await connection.close();
} catch(err) {
console.error(err);
}
}
}
}
그러나 나는 항상 Error : ORA-01461 : can bind a LONG value only for insert into a LONG column을 얻습니다 . 내가 무엇을 놓치고 있습니까?
유니 코드 텍스트 문자열 인 것처럼 이미지 파일을 읽습니다. 그것은 정확하지 않습니다. 버퍼로 읽어야합니다.
var imageBuffer = fs.readFileSync('/path/to/image');
await insertBlob(imageBuffer);
이진 열에 유니 코드 문자열을 삽입하려고하기 때문에 Oracle이 불평한다고 생각합니다. 버퍼를 삽입 해보십시오.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다