Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set object Content-Type in composeObject #1304

Open
realAndDream opened this issue Jun 10, 2024 · 0 comments
Open

how to set object Content-Type in composeObject #1304

realAndDream opened this issue Jun 10, 2024 · 0 comments

Comments

@realAndDream
Copy link

realAndDream commented Jun 10, 2024

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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant