perf
This commit is contained in:
@@ -3,7 +3,7 @@ import { Client, CopyDestinationOptions, CopySourceOptions } from 'minio';
|
||||
type CopyObjectOpts = {
|
||||
bucketName: string;
|
||||
newMetadata: Record<string, string>;
|
||||
prefix: string;
|
||||
objectName: string;
|
||||
client: Client;
|
||||
};
|
||||
/**
|
||||
@@ -11,12 +11,14 @@ type CopyObjectOpts = {
|
||||
* @param param0
|
||||
* @returns
|
||||
*/
|
||||
export const copyObject = async ({ bucketName, newMetadata, prefix, client }: CopyObjectOpts) => {
|
||||
const source = new CopySourceOptions({ Bucket: bucketName, Object: prefix });
|
||||
export const copyObject = async ({ bucketName, newMetadata, objectName, client }: CopyObjectOpts) => {
|
||||
const source = new CopySourceOptions({ Bucket: bucketName, Object: objectName });
|
||||
const stat = await client.statObject(bucketName, objectName);
|
||||
const sourceMetadata = stat.metaData;
|
||||
const destination = new CopyDestinationOptions({
|
||||
Bucket: bucketName,
|
||||
Object: prefix,
|
||||
UserMetadata: newMetadata,
|
||||
Object: objectName,
|
||||
UserMetadata: { ...sourceMetadata, ...newMetadata },
|
||||
MetadataDirective: 'REPLACE',
|
||||
});
|
||||
const copyResult = await client.copyObject(source, destination);
|
||||
|
||||
Reference in New Issue
Block a user