This commit is contained in:
Peter Clement 2024-03-14 19:56:02 +00:00
parent bcd3c0a55c
commit aa89f075cd
2 changed files with 7 additions and 4 deletions

View File

@ -7,11 +7,12 @@ import tar from "tar-fs"
import zlib from "zlib" import zlib from "zlib"
import { promisify } from "util" import { promisify } from "util"
import { join } from "path" import { join } from "path"
import fs, { ReadStream } from "fs" import fs, { PathLike, ReadStream } from "fs"
import env from "../environment" import env from "../environment"
import { bucketTTLConfig, budibaseTempDir } from "./utils" import { bucketTTLConfig, budibaseTempDir } from "./utils"
import { v4 } from "uuid" import { v4 } from "uuid"
import { APP_PREFIX, APP_DEV_PREFIX } from "../db" import { APP_PREFIX, APP_DEV_PREFIX } from "../db"
import fsp from "fs/promises"
const streamPipeline = promisify(stream.pipeline) const streamPipeline = promisify(stream.pipeline)
// use this as a temporary store of buckets that are being created // use this as a temporary store of buckets that are being created
@ -26,7 +27,7 @@ type ListParams = {
type UploadParams = { type UploadParams = {
bucket: string bucket: string
filename: string filename: string
path?: string path?: string | PathLike
type?: string | null type?: string | null
// can be undefined, we will remove it // can be undefined, we will remove it
metadata?: { metadata?: {
@ -160,7 +161,9 @@ export async function upload({
addTTL, addTTL,
}: UploadParams) { }: UploadParams) {
const extension = filename.split(".").pop() const extension = filename.split(".").pop()
const fileBytes = path ? fs.createReadStream(path) : body
const fileBytes = path ? (await fsp.open(path)).createReadStream() : body
const objectStore = ObjectStore(bucketName) const objectStore = ObjectStore(bucketName)
const bucketCreated = await createBucketIfNotExists(objectStore, bucketName) const bucketCreated = await createBucketIfNotExists(objectStore, bucketName)

View File

@ -140,7 +140,7 @@ class RestIntegration implements IntegrationBase {
try { try {
if (filename) { if (filename) {
return handleFileResponse(response, filename) return handleFileResponse(response, filename, this.startTimeMs)
} else { } else {
if (response.status === 204) { if (response.status === 204) {
data = [] data = []