File upload HCL Domino AppDevPack-编写富文本时出现问题
我使用,唯一的区别是读取一个文本文件(body.txt)作为缓冲区,这个文件只包含简单的长文本(40Ko) 执行时,在数据库中创建文档,其余代码不会返回错误。 但最后,富文本字段没有添加到文档中。 这里返回的响应是:File upload HCL Domino AppDevPack-编写富文本时出现问题,file-upload,lotus-domino,hcl,domino-appdev-pack,File Upload,Lotus Domino,Hcl,Domino Appdev Pack,我使用,唯一的区别是读取一个文本文件(body.txt)作为缓冲区,这个文件只包含简单的长文本(40Ko) 执行时,在数据库中创建文档,其余代码不会返回错误。 但最后,富文本字段没有添加到文档中。 这里返回的响应是: response: {"fields":[{"fieldName":"Body","unid":"8EA69129BEECA6DEC1258554002F5DCD","error":{"name":"ProtonError","code":65577,"id":"RICH_TEXT
response: {"fields":[{"fieldName":"Body","unid":"8EA69129BEECA6DEC1258554002F5DCD","error":{"name":"ProtonError","code":65577,"id":"RICH_TEXT_STREAM_CORRUPT"}}]}
我的目标是在富文本字段中编写非常长的文本(超过64KO)。在本例中,我使用了一个文本文件作为缓冲区,但它可能是以后类似于const buffer=buffer.from('very long text…')的内容。
这是正确的方法还是必须采取不同的做法
我使用的是带有IBM Domino(r)服务器(64位)、10.0.1FP4版和AppDevPack 1.0.4版的Windows系统
提前感谢您的帮助
以下是代码:
const write = async (database) => {
let writable;
let result;
try {
// Create a document with subject write-example-1 to hold rich text
const unid = await database.createDocument({
document: {
Form: 'RichDiscussion',
Title: 'write-example-1',
},
});
writable = await database.bulkCreateRichTextStream({});
result = await new Promise((resolve, reject) => {
// Set up event handlers.
// Reject the Promise if there is a connection-level error.
writable.on('error', (e) => {
reject(e);
});
// Return the response from writing when resolving the Promise.
writable.on('response', (response) => {
console.log("response: " + JSON.stringify(response));
resolve(response);
});
// Indicates which document and item name to use.
writable.field({ unid, fieldName: 'Body' });
let offset = 0;
// Assume for purposes of this example that we buffer the entire file.
const buffer = fs.readFileSync('/driver/body.txt');
// When writing large amounts of data, it is necessary to
// wait for the client-side to complete the previous write
// before writing more data.
const writeData = () => {
let draining = true;
while (offset < buffer.length && draining) {
const remainingBytes = buffer.length - offset;
let chunkSize = 16 * 1024;
if (remainingBytes < chunkSize) {
chunkSize = remainingBytes;
}
draining = writable.write(buffer.slice(offset, offset + chunkSize));
offset += chunkSize;
}
if (offset < buffer.length) {
// Buffer is not draining. Whenever the drain event is emitted
// call this function again to write more data.
writable.once('drain', writeData);
}
};
writeData();
writable = undefined;
});
} catch (e) {
console.log(`Unexpected exception ${e.message}`);
} finally {
if (writable) {
writable.end();
}
}
return result;
};
const write=async(数据库)=>{
让它可写;
让结果;
试一试{
//创建一个主题为write-example-1的文档以保存富文本
const unid=await database.createDocument({
文件:{
表格:'RichDiscussion',
标题:“编写示例1”,
},
});
writable=wait database.bulkCreateRichTextStream({});
结果=等待新承诺((解决、拒绝)=>{
//设置事件处理程序。
//如果存在连接级别错误,则拒绝承诺。
可写的.on('error',(e)=>{
拒绝(e);
});
//在解决承诺时返回书面回复。
可写的.on('response',(response)=>{
log(“响应:+JSON.stringify(响应));
决心(回应);
});
//指示要使用的文档和项目名称。
字段({unid,fieldName:'Body'});
设偏移量=0;
//在本例中,假设我们缓冲整个文件。
const buffer=fs.readFileSync('/driver/body.txt');
//在写入大量数据时,有必要
//等待客户端完成上一次写入
//在写入更多数据之前。
常量writeData=()=>{
让我相信你是真的;
while(偏移量
从appdev pack 1.0.4开始,富文本流接受以LMBCS字符集写入有效富文本cd格式的数据。我们目前正在开发一个库,帮助您将有效的富文本数据写入流
我很想听到更多关于您的用例的信息,我们很高兴您已经开始关注这个特性了!如果你能加入openntf slack频道,我通常会在那里闲逛。谢谢你的回答,我会耐心等待。。。我发现appdevpack解决方案非常成功:使用了Domino和NodeJS的最佳功能,而且效果非常好,所有这些新功能对于那些使用Domino进行web开发的人来说都非常有吸引力!!!