Skip to content

how to set object Content-Type in composeObject #1304

@realAndDream

Description

@realAndDream

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions