Merge pull request #14385 from Budibase/fix/14375
App import issue (invalid attachments)
This commit is contained in:
commit
5e35e633c0
|
@ -308,16 +308,21 @@ export async function downloadAttachment(ctx: UserCtx) {
|
|||
if (attachments.length === 1) {
|
||||
const attachment = attachments[0]
|
||||
ctx.attachment(attachment.name)
|
||||
ctx.body = await objectStore.getReadStream(
|
||||
objectStore.ObjectStoreBuckets.APPS,
|
||||
attachment.key
|
||||
)
|
||||
if (attachment.key) {
|
||||
ctx.body = await objectStore.getReadStream(
|
||||
objectStore.ObjectStoreBuckets.APPS,
|
||||
attachment.key
|
||||
)
|
||||
}
|
||||
} else {
|
||||
const passThrough = new stream.PassThrough()
|
||||
const archive = archiver.create("zip")
|
||||
archive.pipe(passThrough)
|
||||
|
||||
for (const attachment of attachments) {
|
||||
if (!attachment.key) {
|
||||
continue
|
||||
}
|
||||
const attachmentStream = await objectStore.getReadStream(
|
||||
objectStore.ObjectStoreBuckets.APPS,
|
||||
attachment.key
|
||||
|
|
|
@ -34,7 +34,7 @@ type TemplateType = {
|
|||
|
||||
function rewriteAttachmentUrl(appId: string, attachment: RowAttachment) {
|
||||
// URL looks like: /prod-budi-app-assets/appId/attachments/file.csv
|
||||
const urlParts = attachment.key.split("/")
|
||||
const urlParts = attachment.key?.split("/") || []
|
||||
// remove the app ID
|
||||
urlParts.shift()
|
||||
// add new app ID
|
||||
|
|
|
@ -44,8 +44,8 @@ export class AttachmentCleanup {
|
|||
if (type === FieldType.ATTACHMENTS && Array.isArray(rowData)) {
|
||||
return rowData
|
||||
.filter(attachment => attachment.key)
|
||||
.map(attachment => attachment.key)
|
||||
} else if ("key" in rowData) {
|
||||
.map(attachment => attachment.key!)
|
||||
} else if ("key" in rowData && rowData.key) {
|
||||
return [rowData.key]
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ export interface RowAttachment {
|
|||
size: number
|
||||
name: string
|
||||
extension: string
|
||||
key: string
|
||||
key?: string
|
||||
// Populated on read
|
||||
url?: string
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue