feat: Bulk HTML export (#4620)
* wip * Working bulk html export * Refactor * test * test
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Transaction } from "sequelize";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { Attachment, Event, User } from "@server/models";
|
||||
import { uploadToS3FromBuffer } from "@server/utils/s3";
|
||||
import { uploadToS3 } from "@server/utils/s3";
|
||||
|
||||
export default async function attachmentCreator({
|
||||
id,
|
||||
@@ -24,7 +24,13 @@ export default async function attachmentCreator({
|
||||
}) {
|
||||
const key = `uploads/${user.id}/${uuidv4()}/${name}`;
|
||||
const acl = process.env.AWS_S3_ACL || "private";
|
||||
const url = await uploadToS3FromBuffer(buffer, type, key, acl);
|
||||
const url = await uploadToS3({
|
||||
body: buffer,
|
||||
contentType: type,
|
||||
contentLength: buffer.length,
|
||||
key,
|
||||
acl,
|
||||
});
|
||||
const attachment = await Attachment.create(
|
||||
{
|
||||
id,
|
||||
|
||||
@@ -1,33 +1,37 @@
|
||||
import { Transaction } from "sequelize";
|
||||
import { APM } from "@server/logging/tracing";
|
||||
import { Collection, Event, Team, User, FileOperation } from "@server/models";
|
||||
import {
|
||||
FileOperationFormat,
|
||||
FileOperationType,
|
||||
FileOperationState,
|
||||
FileOperationFormat,
|
||||
} from "@server/models/FileOperation";
|
||||
} from "@shared/types";
|
||||
import { APM } from "@server/logging/tracing";
|
||||
import { Collection, Event, Team, User, FileOperation } from "@server/models";
|
||||
import { getAWSKeyForFileOp } from "@server/utils/s3";
|
||||
|
||||
type Props = {
|
||||
collection?: Collection;
|
||||
team: Team;
|
||||
user: User;
|
||||
format?: FileOperationFormat;
|
||||
ip: string;
|
||||
transaction: Transaction;
|
||||
};
|
||||
|
||||
async function collectionExporter({
|
||||
collection,
|
||||
team,
|
||||
user,
|
||||
format = FileOperationFormat.MarkdownZip,
|
||||
ip,
|
||||
transaction,
|
||||
}: {
|
||||
collection?: Collection;
|
||||
team: Team;
|
||||
user: User;
|
||||
ip: string;
|
||||
transaction: Transaction;
|
||||
}) {
|
||||
}: Props) {
|
||||
const collectionId = collection?.id;
|
||||
const key = getAWSKeyForFileOp(user.teamId, collection?.name || team.name);
|
||||
const fileOperation = await FileOperation.create(
|
||||
{
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Creating,
|
||||
format: FileOperationFormat.MarkdownZip,
|
||||
format,
|
||||
key,
|
||||
url: null,
|
||||
size: 0,
|
||||
@@ -49,7 +53,8 @@ async function collectionExporter({
|
||||
collectionId,
|
||||
ip,
|
||||
data: {
|
||||
type: FileOperationType.Import,
|
||||
type: FileOperationType.Export,
|
||||
format,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user