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:
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user