From 8a4f062120baffc9e7ac718886da69fd49549bba Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Mon, 7 May 2018 11:19:58 -0400 Subject: [PATCH] Add `MIME.APPLICATION_OCTET_STREAM` --- ts/types/Attachment.ts | 8 +++----- ts/types/MIME.ts | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ts/types/Attachment.ts b/ts/types/Attachment.ts index d37b2f3e34..fccc9962d4 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 620df41c96..43ed14efb0 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;