2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-07-06 21:45:39 -04:00
|
|
|
|
2019-09-02 17:07:11 -04:00
|
|
|
import * as blob from "./blob.ts";
|
2018-11-04 13:05:02 -05:00
|
|
|
|
2020-04-14 09:23:07 -04:00
|
|
|
export class DomFileImpl extends blob.DenoBlob implements File {
|
2018-11-04 13:05:02 -05:00
|
|
|
lastModified: number;
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
constructor(
|
2020-04-11 16:25:31 -04:00
|
|
|
fileBits: BlobPart[],
|
2018-11-04 13:05:02 -05:00
|
|
|
fileName: string,
|
2020-04-14 09:23:07 -04:00
|
|
|
options?: FilePropertyBag
|
2018-11-04 13:05:02 -05:00
|
|
|
) {
|
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
|
|
|
}
|
|
|
|
}
|