mirror of
https://github.com/laosb/ghos3.git
synced 2025-04-30 15:41:08 +00:00
file is streamed rather than buffered to reduce memory usage.
This commit is contained in:
parent
60c201178e
commit
74be77ffdf
1 changed files with 3 additions and 5 deletions
|
@ -6,7 +6,7 @@ import {
|
|||
} from '@aws-sdk/client-s3'
|
||||
import StorageBase, { type ReadOptions, type Image } from 'ghost-storage-base'
|
||||
import { join } from 'path'
|
||||
import { readFile } from 'fs/promises'
|
||||
import { createReadStream } from 'fs'
|
||||
import type { Readable } from 'stream'
|
||||
import type { Handler } from 'express'
|
||||
|
||||
|
@ -152,10 +152,8 @@ class S3Storage extends StorageBase {
|
|||
async save(image: Image, targetDir?: string) {
|
||||
const directory = targetDir || this.getTargetDir(this.pathPrefix)
|
||||
|
||||
const [fileName, file] = await Promise.all([
|
||||
this.getUniqueFileName(image, directory),
|
||||
readFile(image.path),
|
||||
])
|
||||
const fileName = await this.getUniqueFileName(image, directory);
|
||||
const file = createReadStream(image.path)
|
||||
|
||||
let config: PutObjectCommandInput = {
|
||||
ACL: this.acl,
|
||||
|
|
Loading…
Add table
Reference in a new issue