2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2019-09-02 17:07:11 -04:00
|
|
|
import * as domTypes from "./dom_types.ts";
|
|
|
|
import * as blob from "./blob.ts";
|
2018-11-04 13:05:02 -05:00
|
|
|
|
2019-09-23 11:07:13 -04:00
|
|
|
export class DomFileImpl extends blob.DenoBlob implements domTypes.DomFile {
|
2018-11-04 13:05:02 -05:00
|
|
|
lastModified: number;
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
fileBits: domTypes.BlobPart[],
|
|
|
|
fileName: string,
|
|
|
|
options?: domTypes.FilePropertyBag
|
|
|
|
) {
|
2020-03-10 12:08:58 -04:00
|
|
|
const { lastModified = Date.now(), ...blobPropertyBag } = options ?? {};
|
|
|
|
super(fileBits, blobPropertyBag);
|
2018-11-04 13:05:02 -05:00
|
|
|
|
|
|
|
// 4.1.2.1 Replace any "/" character (U+002F SOLIDUS)
|
|
|
|
// with a ":" (U + 003A COLON)
|
|
|
|
this.name = String(fileName).replace(/\u002F/g, "\u003A");
|
|
|
|
// 4.1.3.3 If lastModified is not provided, set lastModified to the current
|
|
|
|
// date and time represented in number of milliseconds since the Unix Epoch.
|
2020-03-10 12:08:58 -04:00
|
|
|
this.lastModified = lastModified;
|
2018-11-04 13:05:02 -05:00
|
|
|
}
|
|
|
|
}
|