Add MIME.APPLICATION_OCTET_STREAM
This commit is contained in:
parent
c8be066391
commit
8a4f062120
2 changed files with 5 additions and 5 deletions
|
@ -4,11 +4,11 @@ import moment from 'moment';
|
||||||
import * as GoogleChrome from '../util/GoogleChrome';
|
import * as GoogleChrome from '../util/GoogleChrome';
|
||||||
import { saveURLAsFile } from '../util/saveURLAsFile';
|
import { saveURLAsFile } from '../util/saveURLAsFile';
|
||||||
import { arrayBufferToObjectURL } from '../util/arrayBufferToObjectURL';
|
import { arrayBufferToObjectURL } from '../util/arrayBufferToObjectURL';
|
||||||
import { MIMEType } from './MIME';
|
import * as MIME from './MIME';
|
||||||
|
|
||||||
export type Attachment = {
|
export type Attachment = {
|
||||||
fileName?: string;
|
fileName?: string;
|
||||||
contentType?: MIMEType;
|
contentType?: MIME.MIMEType;
|
||||||
size?: number;
|
size?: number;
|
||||||
data: ArrayBuffer;
|
data: ArrayBuffer;
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@ interface AttachmentSchemaVersion3 {
|
||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SAVE_CONTENT_TYPE = 'application/octet-stream' as MIMEType;
|
|
||||||
|
|
||||||
export const isVisualMedia = (attachment: Attachment): boolean => {
|
export const isVisualMedia = (attachment: Attachment): boolean => {
|
||||||
const { contentType } = attachment;
|
const { contentType } = attachment;
|
||||||
|
|
||||||
|
@ -57,7 +55,7 @@ export const save = ({
|
||||||
? getAbsolutePath(attachment.path)
|
? getAbsolutePath(attachment.path)
|
||||||
: arrayBufferToObjectURL({
|
: arrayBufferToObjectURL({
|
||||||
data: attachment.data,
|
data: attachment.data,
|
||||||
type: SAVE_CONTENT_TYPE,
|
type: MIME.APPLICATION_OCTET_STREAM,
|
||||||
});
|
});
|
||||||
const filename = getSuggestedFilename({ attachment, timestamp });
|
const filename = getSuggestedFilename({ attachment, timestamp });
|
||||||
saveURLAsFile({ url, filename, document });
|
saveURLAsFile({ url, filename, document });
|
||||||
|
|
|
@ -4,3 +4,5 @@ export const isJPEG = (value: MIMEType): boolean => value === 'image/jpeg';
|
||||||
export const isImage = (value: MIMEType): boolean => value.startsWith('image/');
|
export const isImage = (value: MIMEType): boolean => value.startsWith('image/');
|
||||||
export const isVideo = (value: MIMEType): boolean => value.startsWith('video/');
|
export const isVideo = (value: MIMEType): boolean => value.startsWith('video/');
|
||||||
export const isAudio = (value: MIMEType): boolean => value.startsWith('audio/');
|
export const isAudio = (value: MIMEType): boolean => value.startsWith('audio/');
|
||||||
|
|
||||||
|
export const APPLICATION_OCTET_STREAM = 'application/octet-stream' as MIMEType;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue