PR comments.
This commit is contained in:
parent
5b5e7e47a2
commit
39147b80b6
|
@ -70,6 +70,9 @@ async function processUrlAttachment(
|
||||||
throw new Error(`Unexpected response ${response.statusText}`)
|
throw new Error(`Unexpected response ${response.statusText}`)
|
||||||
}
|
}
|
||||||
const fallbackFilename = path.basename(new URL(attachment.url).pathname)
|
const fallbackFilename = path.basename(new URL(attachment.url).pathname)
|
||||||
|
if (!response.body) {
|
||||||
|
throw new Error("No response received for attachment")
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
filename: attachment.filename || fallbackFilename,
|
filename: attachment.filename || fallbackFilename,
|
||||||
content: stream.Readable.fromWeb(response.body as streamWeb.ReadableStream),
|
content: stream.Readable.fromWeb(response.body as streamWeb.ReadableStream),
|
||||||
|
|
|
@ -163,7 +163,10 @@ async function generateAttachmentRow(attachment: AutomationAttachment) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { filename } = attachment
|
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(
|
const attachmentResult = await objectStore.processAutomationAttachment(
|
||||||
attachment
|
attachment
|
||||||
)
|
)
|
||||||
|
@ -182,8 +185,8 @@ async function generateAttachmentRow(attachment: AutomationAttachment) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
size,
|
size,
|
||||||
|
extension,
|
||||||
name: filename,
|
name: filename,
|
||||||
extension: extension,
|
|
||||||
key: s3Key,
|
key: s3Key,
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in New Issue