HCL Domino AppDevPack-writeAttachments [英] HCL Domino AppDevPack - writeAttachments
问题描述
新的V1.0.2具有将附件上传到多米诺文档的新功能.只要我使用< = 48KB的文件,我的上传代码就会成功.我尝试上传较大的文件后,即会立即进行上传,在多米诺骨牌文档中我找到了大小合适的附件-但文件已损坏!
The new V1.0.2 has new capabilities to upload attachments to a domino document. My upload code is successful as long a I use files <= 48KB. As soon as I try to upload a larger file, the upload takes place, in the domino document I find an attachment with the right size - but the file is corrupt!
这是我的代码(对应于appdev包文档中用于较大文件的示例代码):
Here's my code (corresponds to example code from appdev pack documentation for larger files):
for (var x = 0; x < files["tskFile"].length; x++) {
let sFilename = files["tskFile"][x].originalname;
let sPath = files["tskFile"][x].path;
let buffer = fs.readFileSync(sPath);
const writable = await db.bulkCreateAttachmentStream({});
writable.on('error', e => {
// An error occurred and the stream is closed
console.error("Error on write ", e)
});
writable.on('response', response => {
// The attachment content was written to the document and a
// response has arrived from the server
console.log(">> File " + sFilename + " saved to doc ")
});
let error;
// Write the image in n chunks
let offset = 0;
const writeRemaining = () => {
if (error) {
return;
}
let draining = true;
while (offset < buffer.length && draining) {
const remainingBytes = buffer.length - offset;
let chunkSize = 16 * 1024;
if (remainingBytes < chunkSize) {
chunkSize = remainingBytes;
}
const chunk = new Uint8Array(
buffer.slice(offset, offset + chunkSize),
);
draining = writable.write(chunk);
offset += chunkSize;
}
if (offset < buffer.length) {
// Buffer is not draining. Write some more once it drains.
writable.once('drain', writeRemaining);
} else {
writable.end();
}
};
writable.file({
unid: unid,
fileName: sFilename,
});
writeRemaining();
} // end forall attachments
这是我的服务器的notes.ini变量:
Here are my notes.ini variables for my server:
PROTON_MAX_WRITE_ATTACHMENT_MB=30,
PROTON_MAX_ATTACHMENT_CHUNK_KB=50,
PROTON_MIN_ATTACHMENT_CHUNK_KB=8
我在AppDevPack中的错误或错误?有人尝试过这项新功能吗?
My error or bug in AppDevPack? Did anyone try this new feature?
推荐答案
我们找到了一个修复程序,它将被包含在我们的下一个版本中.谢谢你的报告!
We have found a fix and it will be included in our next drop. Thank you for this report!
这篇关于HCL Domino AppDevPack-writeAttachments的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!