1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-07 20:40:05 +00:00

fix: using mime package to determine content-type

This commit is contained in:
Saad Jutt
2021-05-30 23:47:31 +05:00
parent 56a1960fff
commit c5824a8a8d
3 changed files with 97 additions and 160 deletions

View File

@@ -31,6 +31,7 @@ import { isAuthorizeFormRequired } from './auth/isAuthorizeFormRequired'
import { RequestClient } from './request/RequestClient'
import { SasAuthResponse } from '@sasjs/utils/types'
import { prefixMessage } from '@sasjs/utils/error'
import * as mime from 'mime'
/**
* A client for interfacing with the SAS Viya REST API.
@@ -563,13 +564,8 @@ export class SASViyaApiClient {
'Content-Disposition': `filename="${fileName}";`
}
const mimeType = /.html$/.test(fileName)
? 'text/html'
: /.css$/.test(fileName)
? 'text/css'
: /.js/.test(fileName)
? 'text/javascript'
: 'text/plain'
const mimeType =
mime.getType(fileName.match(/\.[0-9a-z]+$/i)?.[0] || '') ?? 'text/plain'
return (
await this.requestClient.post<File>(