diff --git a/ts/types/Attachment.ts b/ts/types/Attachment.ts index d37b2f3e341..fccc9962d49 100644 --- a/ts/types/Attachment.ts +++ b/ts/types/Attachment.ts @@ -4,11 +4,11 @@ import moment from 'moment'; import * as GoogleChrome from '../util/GoogleChrome'; import { saveURLAsFile } from '../util/saveURLAsFile'; import { arrayBufferToObjectURL } from '../util/arrayBufferToObjectURL'; -import { MIMEType } from './MIME'; +import * as MIME from './MIME'; export type Attachment = { fileName?: string; - contentType?: MIMEType; + contentType?: MIME.MIMEType; size?: number; data: ArrayBuffer; @@ -27,8 +27,6 @@ interface AttachmentSchemaVersion3 { path: string; } -const SAVE_CONTENT_TYPE = 'application/octet-stream' as MIMEType; - export const isVisualMedia = (attachment: Attachment): boolean => { const { contentType } = attachment; @@ -57,7 +55,7 @@ export const save = ({ ? getAbsolutePath(attachment.path) : arrayBufferToObjectURL({ data: attachment.data, - type: SAVE_CONTENT_TYPE, + type: MIME.APPLICATION_OCTET_STREAM, }); const filename = getSuggestedFilename({ attachment, timestamp }); saveURLAsFile({ url, filename, document }); diff --git a/ts/types/MIME.ts b/ts/types/MIME.ts index 620df41c96a..43ed14efb05 100644 --- a/ts/types/MIME.ts +++ b/ts/types/MIME.ts @@ -4,3 +4,5 @@ export const isJPEG = (value: MIMEType): boolean => value === 'image/jpeg'; export const isImage = (value: MIMEType): boolean => value.startsWith('image/'); export const isVideo = (value: MIMEType): boolean => value.startsWith('video/'); export const isAudio = (value: MIMEType): boolean => value.startsWith('audio/'); + +export const APPLICATION_OCTET_STREAM = 'application/octet-stream' as MIMEType;