1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00

PR comments.

This commit is contained in:
mike12345567 2024-05-14 11:23:50 +01:00
parent 5b5e7e47a2
commit 39147b80b6
2 changed files with 8 additions and 2 deletions

View file

@ -70,6 +70,9 @@ async function processUrlAttachment(
throw new Error(`Unexpected response ${response.statusText}`)
}
const fallbackFilename = path.basename(new URL(attachment.url).pathname)
if (!response.body) {
throw new Error("No response received for attachment")
}
return {
filename: attachment.filename || fallbackFilename,
content: stream.Readable.fromWeb(response.body as streamWeb.ReadableStream),

View file

@ -163,7 +163,10 @@ async function generateAttachmentRow(attachment: AutomationAttachment) {
try {
const { filename } = attachment
const extension = path.extname(filename).replaceAll(".", "")
let extension = path.extname(filename)
if (extension.startsWith(".")) {
extension = extension.substring(1, extension.length)
}
const attachmentResult = await objectStore.processAutomationAttachment(
attachment
)
@ -182,8 +185,8 @@ async function generateAttachmentRow(attachment: AutomationAttachment) {
return {
size,
extension,
name: filename,
extension: extension,
key: s3Key,
}
} catch (error) {