minio-js
minio-js copied to clipboard
how to set object Content-Type in composeObject
Hello everyone. I want to upload an mp4 file to minio. I first uploaded the file's fragmented data, and then used composeObject to merge these fragmented files. The objects can be merged into a new object, but its Content-Type is binary/octet-stream. I can't modify the ContentType using UserMetadata. How do I specify this Content-Type? Thanks, the code is following:
async composeFileParts(dto: ComposeFilePartsDto) {
const stream = this.minioClient.listObjects(dto.bucket, `${dto.md5}_`)
const data = (await getReadObjectsNamesStreamData(stream)) as [
{
name: string
},
]
const allIndex: number[] = data.map((value) => {
return parseInt(value.name.substring(value.name.lastIndexOf("_") + 1))
})
allIndex.sort((a, b) => (a < b ? -1 : 1))
const sourceList: minio.CopySourceOptions[] = []
allIndex.forEach((value) => {
const source = new minio.CopySourceOptions({
Bucket: dto.bucket,
Object: `${dto.md5}_${value}`,
})
sourceList.push(source)
})
const destOption = new minio.CopyDestinationOptions({
Bucket: dto.bucket,
Object: `${dto.md5}.${dto.suffix}`,
UserMetadata: {
"Content-Type": "video/mp4",
test: "test",
},
MetadataDirective: "REPLACE",
})
await this.minioClient.composeObject(destOption, sourceList)
}