Amazon S3 error - download html file

Hi,

I use AmazonS3 with Route53 and Cloud Front as webserver for HTML files
When I upload a HTML file to AmazonS3 through Nextcloud and then open the url the file downloads instead of execute like a normal HTML.

I reviewed the file uploaded in S3 and the problem it’s that NextCloud App (External Files) don’t send the metadata that S3 need to know what to do with the file and force to download the file, this happend with (jpg, pdf, html, etc) I fixed the problem in my server, the problem it’s in this file: apps/files_external/lib/Lib/Storage/AmazonS3.php, line: 590 and I put the next code to solve the problem:

/*$this->writeObject($path, $source);*/
/* Start Fix */
$path = $this->normalizePath($path);
$mtime = null;
$metadata = array();
if (is_null($mtime)) {
    $mtime = time();
}

$metadata = [
    'lastmodified' => gmdate(\DateTime::RFC1123, $mtime)
];
	
$mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path);

$this->getConnection()->putObject([
    'Bucket' => $this->bucket,
    'Key' => $this->cleanKey($path),
    'Metadata' => $metadata,
    'Body' => $source,
    'ContentType' => $mimeType,
    'MetadataDirective' => 'REPLACE',
]);

/* End Fix */

I hope that this help and fix this to future updates

Thanks