feat(s3): set content type from stream when uploading (#4460)

Co-authored-by: guopeilun <guopl@flatincbr.com>
This commit is contained in:
plzzzzg 2023-05-24 18:02:49 +08:00 committed by GitHub
parent 645c10c11f
commit 6b97b4eb20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,11 +136,13 @@ func (d *S3) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreame
uploader.PartSize = stream.GetSize() / (s3manager.MaxUploadParts - 1)
}
key := getKey(stdpath.Join(dstDir.GetPath(), stream.GetName()), false)
contentType := stream.GetMimetype()
log.Debugln("key:", key)
input := &s3manager.UploadInput{
Bucket: &d.Bucket,
Key: &key,
Body: stream,
Bucket: &d.Bucket,
Key: &key,
Body: stream,
ContentType: &contentType,
}
_, err := uploader.UploadWithContext(ctx, input)
return err